I'm a begginer with php and mysql, I have a problem with a form, I cannot insert the variables into the database, it only adds blank spaces... I tried inserting them directly to the database without the variables and it seems to work...
Let me include what i have so far...i'm really stressed out about this problem, I havent been able to resolve it for the past 2 weeks...
<html>
<body>
<form action="<?php echo $_server['php_self'];?>" name="foward" method="post">
Estudent Name:<input type="text" name="name" value="<? echo $name; ?>"> <br>
Address:<input type="text" name="address" value="<? echo $address; ?>"> <br>
Control Number:<input type="text" name="control_num" value="<? $control_num; ?>"> <br>
Career:<select>
<option value=\"none\" selected> Select One </option>
<option value="LAE">LAE</option>
<option value="LI">LI</option>
<option value="IS">IS</option>
<option value="LC">LC</option>
</select>
<input type="Submit" name="Submit" value="Submit">
</form>
</body>
</html>
<?php
$link=mysql_connect("localhost","root");
if(!link) {
die("Not connected:" . mysql_error());
}
$db_selected=mysql_select_db("practice");
if(!$db_selected){
die("Can't use foo: ". mysql_error());
}
$sql ="insert into table1";
$sql .="(num,name,address,control_num,career)";
$sql .="values('','$name','$address','$control_num','$career')";
mysql_query($sql);
$query= "select * from table1";
$result= mysql_query($query);
while ($fila=mysql_fetch_object($result)){
$ident=$fila->num;
$nombre=$fila->name;
$direccion=$fila->address;
$num_control=$fila->control_num;
$carrera=$fila->career;
echo $ident." ".$name." ".$address." "."<br>";
echo $control_num." ".$career." "."<br>";
}
echo "Thank you\n";
?>