doforumda Posted October 7, 2009 Share Posted October 7, 2009 hi my html page is here <html> <head> <title>Untitled Document</title> </head> <body> <form method="post" action="feedback.php"> <label>Name: <input name="user" type="text" maxlength="40" size="40"> </label> <p> <label>Email: <input type="text" name="email"> </label> </p> <p> <label>Comments: <textarea name="comments" cols="45" rows="5"></textarea> </label> </p> <p> <label> <input type="submit" value="Submit"> </label> </p> </form> </body> </html> and php code is here <body> <?php if(!$user || !$email || !$comments) { echo "Fill in all fields."; exit; } $user = addslashes($user); $email = addslashes($email); $comments = addslashes($comments); $db = mysql_connect("localhost"); mysql_select_db("videoshop", $db); $addfeedback = "insert into feedback (name,email,comments) values('".$user."','".$email."','".$comments."')"; $result = mysql_query($addfeedback) or die(mysql_error()); echo "Thank you your data is added."; ?> </body> </html> the problem i am facing is when i fill all the textfields in html page and submit it the on php side it says "Notice: Undefined variable: user in D:\wamp\www\feedback\feedback.php on line 10 Fill in all fields." how can this problem be fixed? Link to comment https://forums.phpfreaks.com/topic/176794-need-help-in-php-code-for-inserting-data-to-mysql-db/ Share on other sites More sharing options...
fooDigi Posted October 7, 2009 Share Posted October 7, 2009 it says there is an undefined variable "user", where is "$user" set, and how was it passed.... work backwords from the errors... Link to comment https://forums.phpfreaks.com/topic/176794-need-help-in-php-code-for-inserting-data-to-mysql-db/#findComment-932150 Share on other sites More sharing options...
doforumda Posted October 7, 2009 Author Share Posted October 7, 2009 i know what that means but how can i fix this can you tell me where i am making mistake i tried alot to figure out the mistake but couldnt find it. Link to comment https://forums.phpfreaks.com/topic/176794-need-help-in-php-code-for-inserting-data-to-mysql-db/#findComment-932153 Share on other sites More sharing options...
fooDigi Posted October 7, 2009 Share Posted October 7, 2009 you must learn basic debugging skills, which i will not teach.... and complete sentence... when you can..lol phpfreaks, google, and many other sources have tutorials on how to do most anything you want... lol Link to comment https://forums.phpfreaks.com/topic/176794-need-help-in-php-code-for-inserting-data-to-mysql-db/#findComment-932158 Share on other sites More sharing options...
doforumda Posted October 7, 2009 Author Share Posted October 7, 2009 when i echo my query "echo $addfeedback;" then it says "Fill in all fields.insert into feedback (name,email,comments) values('','[email protected]','mike')Thank you your data is added." Link to comment https://forums.phpfreaks.com/topic/176794-need-help-in-php-code-for-inserting-data-to-mysql-db/#findComment-932220 Share on other sites More sharing options...
Bendude14 Posted October 7, 2009 Share Posted October 7, 2009 You need to access the data from your form using $_POST['user'] etc.... Link to comment https://forums.phpfreaks.com/topic/176794-need-help-in-php-code-for-inserting-data-to-mysql-db/#findComment-932349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.