Jump to content
Sign in to follow this  
terryds

[SOLVED]Help me ' Undefined index: lname ' !

Recommended Posts

Hello, all! I want to create a sign-up page, then i make signup.html and signup.php ...The signup html goes well, but the signup php doesn't.. Please check what's wrong with my code... signup.html

 <!DOCTYPE html><html><head><title>Sign Up Now!</title><link rel="stylesheet" type="text/css" href="signup.css" /></head><body><h1>Sign up now and get the gifts!<h1><h3>Type down your identity !</h3><form method="post" action="signup.php"><fieldset><legend>Sign Up</legend><label for="fname">First Name:</label><input type="text" id="fname" name="fname" /> <label for="lname">Last Name:</label><input type="text" id="lname" name"lname" /> <label for="email">Email</label><input type="text" id="email" name="email" /> <label for="country">Country</label><input type="text" id="country" name="country" /> <label for="gender">Gender</label><input id="gender" name="gender" type="radio" value="male">Male<input id="gender" name="gender" type="radio" value="female">Female <label for="reason">Why do you want to join us ?</label><textarea id="reason" name="reason"></textarea> <input type="submit" value="Sign Up!" name="submit" /></fieldset></form></body></html>

signup.php

 <!DOCTYPE html><html><head><title>Thanks for signing up!</title></head><body><h2>Wait till the admin validates your account</h2><?php$name = $_POST['fname'] . " " . $_POST['lname'];$email = $_POST['email'];$country = $_POST['country'];$gender = $_POST['gender'];$reason = $_POST['reason']; echo 'Thanks for signing up, ' . $name . '';echo 'Those datas you input will be emailed to admin' . '';echo 'Name : ' . $name . '';echo 'Email : ' . $email . '<br/>';echo 'Country : ' . $country . '';echo 'Gender : ' . $gender . '';echo 'I join this because ' . $reason;?> </body></html>

When i fill in the form, then submit them.. Then the signup.php appears and the output is below

 Wait till the admin validates your account  Notice: Undefined index: lname in C:xampphtdocsphpsignup.php on line 9Thanks for signing up, aaaaThose datas you input will be emailed to adminName : aaaaEmail : aaaa@aa.comCountry : aaaaGender : maleI join this because i like it

Please fix this... P.S. I run it in localhost

Edited by terryds

Share this post


Link to post
Share on other sites

The HTML of your form has a mistake in it. You should look for it.

Share this post


Link to post
Share on other sites

Umm.. I just notice one mistake and it doesn't fix the problem... The code <h1>Sign up now and get the gifts!<h1> Should be

<h1>Sign up now ad get the gifts!</h1>

Can someone please tell where the problem is for me?

Edited by terryds

Share this post


Link to post
Share on other sites

Solved !!!I have found one more mistake and it solved the problem !! This code doesn't have the equal sign... :facepalm:

name"lname"

Hahahah... I feel so ashamed..

Share this post


Link to post
Share on other sites

Things like this are pretty easy to solve, you just have to believe what the computer says. It's telling you that there isn't an item called "lname" (although that's the only error, so it found everything else), so you just need to look at that lname field to figure out why it can't find only that one. Glad you caught it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×