PDA

View Full Version : مشکل در فرم ثبت نام



mrr1375
یک شنبه 11 مهر 1395, 02:07 صبح
با عرض سلام کسی میدونه ایراد این کد چیه که هرکاری میکنم عمل نمیکنه؟؟؟؟ارور هم نمیده ولی هروقت جدولمو چک مینم چیزی اضافه نشده بهش!!!!
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>


<body>
<form id="form4" name="form4" method="post" action="">
<table width="226" height="258" border="0">
<tr>
<td width="220"><label for="tb1"></label>
<input name="tb1" type="text" id="tb1" value="username" /></td>
</tr>
<tr>
<td><label for="tb2"></label>
<input name="tb2" type="text" id="tb2" value="password" /></td>
</tr>
<tr>
<td><label for="tb3"></label>
<input name="tb3" type="text" id="tb3" value="email" /></td>
</tr>
<tr>
<td><label for="number"></label>
<input name="number" type="text" id="tb4" value="number" /></td>
</tr>
<tr>
<td><input type="submit" name="bt" id="bt" value="register" /></td>
</tr>
</table>
</form>
<?php
if(isset($_['tb1']) && isset($_POST['tb2']) && isset($_POST['tb3']) && isset($_POST['tb4']))
{
$user=$_POST['name'];['tb1'];
$pass=$_POST['name'];['tb2'];
$em=$_POST['name'];['tb3'];
$num=$_POST['name'];['tb4'];
$con=mysql_connect("localhost","root","");
mysql_select_db("user_table",$con);
$sql="INSERT INTO form(`name`,`lname`,`email`,`sh`)
VALUES('$user','$pass','$em','$num')";
$Result = mysql_query($Sql) or die(mysql_error() . "<br>SQL: " . $Sql);
print("Registration Complete Successfully!");
}
?>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------------------

programer1987
چهارشنبه 14 مهر 1395, 19:43 عصر
دوست عزیز این فرم نیست یک دنیا اشتباه هستش برای مثال یکی از اشتباهات :

if(isset($_['tb1']) && isset($_POST['tb2']) && isset($_POST['tb3']) && isset($_POST['tb4']))


که بعد از دستور if همون خط اول $_ که گذاشتید POST نیست و همینطور همه خط ها ی دیگه و اینکه شما MYSQL دیگه منسوخ شده حداقل MYSQLI و در حالت بهتر PDO بزنید.

اگه واجبه بگید فیلد هایی که می خواهید چیه براتون یه فرم با مستندات بزنم و تقدیم کنم.