aub Posted April 27, 2014 Share Posted April 27, 2014 Design a form that accept your first name, last name and email address. Use GET for posting the form into the same php page, print out the result: (first_name, last_name, and email_address after the form is being submitted, you must validate your first_name, last_name are alphabetic, and your email address is valid. Also all fields must be mandatory. I don't know how to make first name and last name alphabetic and email address valid. This is my code: <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> <title>PHP Scripting</title> </head> <body> <h1>TASK 3: Question 4</h1> <?php if (isset($_GET['Submit'])) { echo "inside the form". $_GET['Submit'] . "<br>"; $firstname = $_GET['fname']; $lastname = $_GET['lname']; $DOB = $_GET['dob']; if(empty($_GET['fname']) || empty($_GET['lname']) || empty($_GET['dob'])) { echo 'Please fill in all of the fields.'; } else { $firstname = $_GET['fname']; $lastname = $_GET['lname']; $dob = $_GET['dob']; if(ucfirst($firstname) != $firstname || ucfirst($lastname) != $lastname) { echo 'The first letter of your first and last name must be in upper case.'; } else { echo 'Thank you ' . htmlspecialchars($firstname) . ' ' . htmlspecialchars($lastname) . ', for entering your date of birth: ' . htmlspecialchars($dob) . '<br />'; } } } else { ?> <form action="getform.php", method="get"> <p>First Name: <input type="text" name="fname" value=""/></p> <p>Last Name: <input type="text" name="lname" value=""/></p> <p>DOB: <input type="date" name="dob" value=""/></p> <p><input type="submit" name="Submit" value="Submitted"/></p> <?php echo "not in form yet"; echo "<br>" . $_SERVER['PHP_SELF']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/288062-please-help/ Share on other sites More sharing options...
aub Posted April 27, 2014 Author Share Posted April 27, 2014 Your help would be appreciated! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/288062-please-help/#findComment-1477446 Share on other sites More sharing options...
ginerjm Posted April 27, 2014 Share Posted April 27, 2014 Have you tried to google this problem? Very first response to a simple search returned the exact php function you need. Quote Link to comment https://forums.phpfreaks.com/topic/288062-please-help/#findComment-1477453 Share on other sites More sharing options...
aub Posted April 27, 2014 Author Share Posted April 27, 2014 Yes I've tried and couldn't find it :s Quote Link to comment https://forums.phpfreaks.com/topic/288062-please-help/#findComment-1477459 Share on other sites More sharing options...
ginerjm Posted April 27, 2014 Share Posted April 27, 2014 really? If you need to be taught how to use google to find things, then your php learning curve is going to be a very, very long one. I suggest you give it a try again. Type in "php check for alphabetic". Quote Link to comment https://forums.phpfreaks.com/topic/288062-please-help/#findComment-1477461 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.