pmi Posted March 4, 2013 Share Posted March 4, 2013 I had this working before. I have errors in PHP and I don't think the code will run. Any suggestions would be much appreciated, <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><link href="test.css" rel="stylesheet" type="text/css" /></head><body><div class="container"> <div class="header"><!-- end .header --></div> <div id="h-navbar"><a href="#">Home</a> | <a href="#">About Us</a> | <a href="#">Contact Us</a></div> <div class="sidebar1"> <ul class="nav"> <li><a href="#">Inventory</a></li> <li><a href="#">Financing</a></li> <li><a href="#">Service</a></li> <li><a href="#">Promotions</a></li> </ul> <p>sidebar</p> <p>(hours & location)</p> <!-- end .sidebar1 --></div> <div class="content"> <h1 align="center">Sign up for Deals & Special Offers!</h1> <?php$displayForm = true;if (isset($_POST['submit'])){$displayForm = false;}if (isset($_POST['username'], $_POST['email'], $_POST['age'], $_POST['password'])){$errors = array();$username = $_POST['username'];$age = $_POST['age'];$email = $_POST['email'];$password = $_POST['password'];/*if (empty($name) || empty($age) || empty($email) || empty($password)){$errors[] = 'All fields are required!';}else*///allows only letters and numbers for usernameif (!ctype_alnum($username)){ $errors[] = 'Name must contain a combination of letters and numbers only!'; }// age must be numericif (!preg_match ("/^([0-9]+)$/", $age)){$errors[] = 'Age must be a number!';}//email must be validif (!filter_var($email, FILTER_VALIDATE_EMAIL) == true){$errors[] = 'You must enter a valid email!';}//password must be between 8 and 16 characters in length//password must only contain letters and numbersif (!preg_match("/^[a-z0-9]{8,16}$/i", $password)){$errors[] = 'Password invalid, must be between 8 and 16 characters!';}// if there are validation errors, loops and outputs errors stored in arrayif (!empty($errors)){foreach ($errors as $error){echo $error;}}//if there are no validation errors, confirms registrationelse{echo "Thanks for registering!"echo "Your username is: " . $usernameecho "Your email address is: " . $emailecho "Your age is: " . $age,echo "Your password is: " . $password$file_name = fopen('registrationfile.csv', 'a+');$record = array( $username, $email, $age, $password);fputcsv($file_name, $record);fclose($file_name);}}if ($displayForm){?><p><form action="" method="post"><label>Username:</label> <input type="text" name="username" /><br><label>Email:</label> <input type="text" name="email" /><br><label>Age:</label> <input type="text" name="age" /><br><label>Password:</label> <input type="password" name="password" /><br><input type="submit" name="submit" value="Register" /></form><p> <p>content</p> <!-- end .content --></div> <div class="footer"> <p>Copyright 2013 - Quality Auto Group</p> <!-- end .footer --></div><!-- end .container --></div></body></html> Link to comment https://forums.phpfreaks.com/topic/275229-html-and-php-error/ Share on other sites More sharing options...
haku Posted March 4, 2013 Share Posted March 4, 2013 Probably something wrong in there. Link to comment https://forums.phpfreaks.com/topic/275229-html-and-php-error/#findComment-1416479 Share on other sites More sharing options...
Christian F. Posted March 4, 2013 Share Posted March 4, 2013 Please use the [code][/code] tags around your code, as it helps make both your post and your code a lot easier to read. Not to mention, explain your problem in detail. With examples of what you want, and what you are actually getting. After all, the more information you give us, the easier it'll be for us to help you. Link to comment https://forums.phpfreaks.com/topic/275229-html-and-php-error/#findComment-1416514 Share on other sites More sharing options...
Guest lenix Posted March 7, 2013 Share Posted March 7, 2013 Try to change this lines to: echo "Thanks for registering!"; echo "Your username is: $username"; echo "Your email address is: $email"; echo "Your age is: $age"; echo "Your password is: $password"; Link to comment https://forums.phpfreaks.com/topic/275229-html-and-php-error/#findComment-1417149 Share on other sites More sharing options...
Christian F. Posted March 7, 2013 Share Posted March 7, 2013 That was one out of four questions filled. Plus an infraction by hijacking someone else's thread. You're not making it easy, nor very desirable to help you, you know. Why should we spend our free time to try to help you, when you're not even taking the time to read our posts (or rules) properly? We're here to help those who want to learn, not to waste our time or work for free. Link to comment https://forums.phpfreaks.com/topic/275229-html-and-php-error/#findComment-1417164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.