Haha left it for awhile and did other stuff now I have to sort this out. Pretty stuck here. I created the form and database etc. I created the php code to connect and retrieve the information, however the values return blank. Although some sort of info is still submitted as the sno field gets updated everytime I submit. Only the sno field with its auto increment has a value the rest of the fields remain blank.
For now I have a seperate form (student_reg.php) and a file with the code (demo.php) know its not the right structure but its only for now until I get it working.
Heres my html form student_reg.php
Language: PHP
<div id="apdiv3">
<FORM action = "demo.php" method ="post ">
<p>Course name:</p>
<INPUT TYPE = "text" name="input"/>
<INPUT TYPE = "Submit" VALUE = "Submit"/>
</div>
</FORM>
and heres my php code. The connection to the database is successful, it just doesn't return the values I submit in the form to the database but picks up that something is being submitted as the sno field gets updated each time I submit.
Language: PHP
<?PHP
include ';includes/config.php';;
//connect to database
$link=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
//error check
if (!$link)
{
die(';could not connect: '; . mysql_error());
}
$db_selected=mysql_select_db(DB_NAME, $link);
// error check
if (!$db_selected)
{
die(';can\t use '; . DB_NAME . ';: '; . mysql_error());
}
// Connected to database
// retrieve form data
$value=(isset($_POST[';input';]));
$sql = "INSERT INTO student (sname) VALUES (';$value';)";
if (!mysql_query($sql))
{
die (';Error: '; . mysql_error());
}
mysql_close();
?>
I used to get a notice "undefined index" originating from my "$value=(isset($_POST['input']));" line. However, that dissapeared
when adding "isset" to the line. Don't know If that solved a problem or is just hiding it but just thought I'd share.
Hope someone can help kinda stuck here.