Announcements | Last Post | |
---|---|---|
SoC Curricula | 09/30/2017 01:08PM | |
Demarcation or scoping of examinations and assessment | 02/13/2017 07:59AM | |
School of Computing Short Learning Programmes | 11/24/2014 08:37AM | |
Unisa contact information | 07/28/2011 01:28PM |
getting values from the form April 03, 2013 01:19AM |
Registered: 11 years ago Posts: 56 Rating: 0 |
Re: getting values from the form April 03, 2013 07:51AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: getting values from the form April 03, 2013 10:46AM |
Registered: 11 years ago Posts: 56 Rating: 0 |
Re: getting values from the form April 03, 2013 01:26PM |
Registered: 11 years ago Posts: 56 Rating: 0 |
Re: getting values from the form April 03, 2013 01:56PM |
Registered: 11 years ago Posts: 163 Rating: 0 |
Re: getting values from the form April 03, 2013 02:02PM |
Registered: 11 years ago Posts: 36 Rating: 0 |
Re: getting values from the form April 03, 2013 09:20PM |
Registered: 11 years ago Posts: 56 Rating: 0 |
Re: getting values from the form April 29, 2013 03:28PM |
Registered: 11 years ago Posts: 56 Rating: 0 |
Language: PHP<html> <head><title></title> </head> <?php $user_name = "root"; $password = ""; $database = "amahlomuka"; $server = "127.0.0.1"; $db_handle = mysql_connect($server,$user_name,$password); $db_found = mysql_select_db($database , $db_handle); if($db_found) { if(isset($_POST[';reg';])) { $name = $_POST[';name';]; $sname = $_POST[';sname';]; $gen = $_POST[';gen';]; $cell = $_POST[';cell';]; $email = $_POST[';email';]; $user_name= $_POST[';user_name';]; $passw = $_POST[';passw';]; echo $name." ".$sname." ".$gen." ".$cell." ".$email." ".$user_name." ". $passw ."<br> " ; $SQL = "INSERT INTO `amahlomuka`.`tb_reg` (`name`, `sname`, `gen`, `cell`, `email`, `user_name`, `passw`) VALUES (`$name`, `$sname`, `$gen`, `$cell`, `$email`, `$user_name`, `$passw`);"; $result = mysql_query($SQL); echo "registered"."<br>"; } $SQL = "SELECT * FROM tb_reg "; $result = mysql_query($SQL); while ($db_field = mysql_fetch_assoc($result)) { echo $db_field[';name';]." "; echo $db_field[';sname';]." "; echo $db_field[';gen';]." "; echo $db_field[';cell';]." "; echo $db_field[';email';]." "; echo $db_field[';user_name';]." "; echo $db_field[';passw';]." " ."<br>"; } } else { print "database not found"; } ?> <body> <form name="login" action="ifdb_found.php" method="post"> <table name="login" width="70%" align="center" height="12%"> <tr> <td align="right">User Name<td> <td><input type="text" name="name" value=""><td> <td align="right">Password<td> <td><input type="text" name="passw" value=""><td> </tr> <tr align="center"> <td colspan="8" ><input type="submit" name="log" value="LOGIN"><td> </tr> </table> </form> <hr width="70%" align="center" height="2%" color="blue"> <form name="reg" action="ifdb_found.php" method="post"> <table name="reg" width="70%" height="45%"align="center"> <tr> <td align="right">Name<td> <td><input type="text" name="name" value=""><td> </tr> <tr> <td align="right">Surname<td> <td><input type="text" name="sname" value=""><td> </tr> <tr> <td align="right">Gender<td> <td><input type="text" name="gen" value=""><td> </tr> <tr> <td align="right">Cell Number<td> <td><input type="text" name="cell" value=""><td> </tr> <tr> <td align="right">E-Mail<td> <td><input type="text" name="email" value=""><td> </tr> <tr> <td align="right">User Name<td> <td><input type="text" name="user_name" value=""><td> </tr> <tr> <td align="right">Password<td> <td><input type="password" name="passw" value=""><td> </tr> <tr align="center"> <td colspan="4" ><input type="submit" name="reg" value="REGISTER NOW"><td> </tr> </body> </table> </form> </html>
Re: getting values from the form April 29, 2013 03:48PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Language: PHP$result = mysql_query($SQL) or die(mysql_error());
Language: PHP// (name, sname`, `gen`, `cell`, `email`, `user_name`, `passw`) you only need to use this if you are not inserting into all the columns, typically used more with an update function $SQL = "INSERT INTO amahlomuka.tb_reg VALUES (`$name`, `$sname`, `$gen`, `$cell`, `$email`, `$user_name`, `$passw`);"; // you have an extra ; here after the closing )... this );"; should be )"; //this will work, from another example $query=mysql_query("INSERT into reports VALUES ( ';';, //here I cover for an auto increment field, two single quotes ';$fid';, ';$date';, ';$teama';, ';$teamh';, ';$scorea';, ';$scoreh';, ';$ref_id';, ';$r1';, ';$r2';, ';$r3';, ';$r4';, ';$r5';, ';$r6';, ';$r7';, ';$r8';, ';$mark';) ");
Re: getting values from the form April 30, 2013 06:36AM |
Registered: 11 years ago Posts: 38 Rating: 0 |
Re: getting values from the form May 01, 2013 01:09AM |
Registered: 11 years ago Posts: 56 Rating: 0 |