Welcome! Log In Create A New Profile

Advanced

getting values from the form

Posted by 78042968 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
getting values from the form
April 03, 2013 01:19AM
Mac. I been trying for a while now. When trying to get values from the form i get an error in line 6( $user_name=$_post['username']winking smiley is there anythng wrong here?

Sihle
avatar
Mac
Re: getting values from the form
April 03, 2013 07:51AM
Use formatted code button to post code.....!

The CASE of $_post is uppercase. That is how it is shown in the tut, so you need to give attention to what and how you type.

Language: PHP
$username = $_POST[';username';];
Re: getting values from the form
April 03, 2013 10:46AM
Thanks mac i will be working on it today
Re: getting values from the form
April 03, 2013 01:26PM
What do you mean about formatted button code? Language php: <? Php if(asset($_POST['submit'])) { if(user_name=="sihle"winking smiley { print ("welcome back"winking smiley;} else { print ("you are not a member"winking smiley;}} ?> plz give me an example of wht you saying
Re: getting values from the form
April 03, 2013 01:56PM
if you look at your post you will notice that if you have a semi-colon and a closing bracket - it will be converted to a smiley face.

to avoid this on your menu bar (just above the where you write your comments) - there will be a button to format code. it Is the 6th button if you from right.

if you click on it should give you some thing like code="php" - you must write between "code tags"
Re: getting values from the form
April 03, 2013 02:02PM
Language: PHP
"and then your code looks awesome like this"

http://capetown-airport.co.za/
Re: getting values from the form
April 03, 2013 09:20PM
Language: PHP
print ("thanks a lot kreason_77840070 and 77911997 ");
Re: getting values from the form
April 29, 2013 03:28PM
i was pracising but the line that insert data does not work and i dont find error here please halp

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>
avatar
Mac
Re: getting values from the form
April 29, 2013 03:48PM
A lot of code to check... sad smiley an it is easy to miss a typo.

Add an "or die" check to print out errors

Language: PHP
$result = mysql_query($SQL) or die(mysql_error());

Also, there is a difference between the use of a back tick ` , " and '

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';) ");
avatar Re: getting values from the form
April 30, 2013 06:36AM
Hi there, I also had a similar issue earlier, and was about to tear my hair out when I noticed that I misspelled the table name, so I can also suggest to check table and field names with a fine tooth comb, like Mac already mentioned, especially with long and complicated SQL statements. It's easy to miss an extra s somewhere. Hope this helps a bit. Cheers.
Re: getting values from the form
May 01, 2013 01:09AM
Thanks. I think I need more in being carefull with
these small things here
Sorry, only registered users may post in this forum.

Click here to login