I get an unexpected error.. Sorry I am kinda new with PHP Parse error: syntax error, unexpected '<' in /home/l on line 61 Spoiler <?php session_start() ?> <?php //init variables $cf = array(); $sr = false; if(isset($_SESSION['cf_returndata'])){ $cf = $_SESSION['cf_returndata']; $sr = true; } ?> <!doctype html> <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>HTML5 Contact Form</title> <meta name="description" content=""> <meta name="author" content=""> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="stylesheet" href="http:insert.style.css"> <script src="js/libs/modernizr-1.7.min.js"></script> </head> <body> <div id="container"> <title>Contact Form</title> <meta name="description" content=""> <meta name="author" content=""> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="stylesheet" href="http://homer.pw/style.css"> <script src="js/libs/modernizr-1.7.min.js"></script> </head> <body> <div id="container"> <div id="contact-form" class="clearfix"> <h1>Get In Touch!</h1> <h2>F</h2> <?php //init variables $cf = array(); $sr = false; if(isset($_SESSION['cf_returndata'])){ $cf = $_SESSION['cf_returndata']; $sr = true; } <ul id="errors" class="<?php echo ($sr && !$cf['form_ok']) ? 'visible' : ''; ?>"> <li id="info">There were some problems with your form submission:</li> <?php if(isset($cf['errors']) && count($cf['errors']) > 0) : foreach($cf['errors'] as $error) : ?> <li><?php echo $error ?></li> <?php endforeach; endif; ?> </ul> <form method="post" action="process.php"> <label for="name">Name: <span class="required">*</span></label> <input type="text" id="name" name="name" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['name'] : '' ?>" placeholder="John Doe" required autofocus /> <label for="email">Email Address: <span class="required">*</span></label> <input type="email" id="email" name="email" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['email'] : '' ?>" placeholder="" required /> <label for="telephone">Telephone: </label> <input type="tel" id="telephone" name="telephone" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['telephone'] : '' ?>" /> <label for="enquiry">Enquiry: </label> <select id="enquiry" name="enquiry"> <option value="General" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'General') ? "selected='selected'" : '' ?>>General</option> <option value="Sales" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'Sales') ? "selected='selected'" : '' ?>>Sales</option> <option value="Support" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['inquiry'] == 'Support') ? "selected='selected'" : '' ?>>Support</option> </select> <label for="message">Message: <span class="required">*</span></label> <textarea id="message" name="message" placeholder="Your message must be greater than 20 characters" required data-minlength="20"><?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['message'] : '' ?></textarea> <span id="loading"></span> <input type="submit" value="Holla!" id="submit-button" /> <p id="req-field-desc"><span class="required">*</span> indicates a required field</p> </form> <?php unset($_SESSION['cf_returndata']); ?> </div>
You're mixing PHP and HTML. I suggest you learn to echo the HTML instead of opening and closing PHP tags all the time.
this: $sr = true; } <ul id="errors" class="<?php echo ($sr && !$cf['form_ok']) ? 'visible' : ''; ?>"> PHP: should be: $sr = true; } ?> <ul id="errors" class="<?php echo ($sr && !$cf['form_ok']) ? 'visible' : ''; ?>"> PHP:
Now I'm getting a different error: Original line of 72 was if(isset($cf['errors']) && count($cf['errors']) > 0) : PHP: Parse error: syntax error, unexpected 'if' (T_IF) in /on line 72 Code Spoiler <?php session_start() ?> //init variables $cf = array(); $sr = false; if(isset($_SESSION['cf_returndata'])){ $cf = $_SESSION['cf_returndata']; $sr = true; } ?> <!doctype html> <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Contact US</title> <meta name="description" content=""> <meta name="author" content=""> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="stylesheet" href="http://unknow/style.css"> <script src="js/libs/modernizr-1.7.min.js"></script> </head> <body> <div id="container"> <div id="contact-form" class="clearfix"> <h1>Get In Touch!</h1> <h2></h2> <?php //init variables $cf = array(); $sr = false; if(isset($_SESSION['cf_returndata'])){ $cf = $_SESSION['cf_returndata']; $sr = true; } ?> <ul id="errors" class="<?php echo ($sr && !$cf['form_ok']) ? 'visible' : ''; ?>"> <li id="info">There were some problems with your form submission:</li> <?php if(isset($cf['errors'])) { foreach($cf['errors'] as $error) { ?> <li><?php echo $error ?></li> <?php endforeach; endif; ?> </ul> <form method="post" action="process.php"> <label for="name">Name: <span class="required">*</span></label> <input type="text" id="name" name="name" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['name'] : '' ?>" placeholder="John Doe" required autofocus /> <label for="email">Email Address: <span class="required">*</span></label> <input type="email" id="email" name="email" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['email'] : '' ?>" placeholder="johndoe@example.com" required /> <label for="telephone">Telephone: </label> <input type="tel" id="telephone" name="telephone" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['telephone'] : '' ?>" /> <label for="enquiry">Enquiry: </label> <select id="enquiry" name="enquiry"> <option value="General" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'General') ? "selected='selected'" : '' ?>>General</option> <option value="Sales" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'Sales') ? "selected='selected'" : '' ?>>Sales</option> <option value="Support" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'Support') ? "selected='selected'" : '' ?>>Support</option> </select> <label for="message">Message: <span class="required">*</span></label> <textarea id="message" name="message" placeholder="Your message must be greater than 20 charcters" required data-minlength="20"><?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['message'] : '' ?></textarea> <span id="loading"></span> <input type="submit" value="Holla!" id="submit-button" /> <p id="req-field-desc"><span class="required">*</span> indicates a required field</p> </form> <?php unset($_SESSION['cf_returndata']); ?> </div> PHP:
i think its okay now <?php session_start(); //init variables $cf = array(); $sr = false; if(isset($_SESSION['cf_returndata'])){ $cf = $_SESSION['cf_returndata']; $sr = true; } ?> <!doctype html> <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Contact US</title> <meta name="description" content=""> <meta name="author" content=""> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="stylesheet" href="http://unknow/style.css"> <script src="js/libs/modernizr-1.7.min.js"></script> </head> <body> <div id="container"> <div id="contact-form" class="clearfix"> <h1>Get In Touch!</h1> <h2></h2> <?php //init variables $cf = array(); $sr = false; if(isset($_SESSION['cf_returndata'])){ $cf = $_SESSION['cf_returndata']; $sr = true; } ?> <ul id="errors" class="<?php echo ($sr && !$cf['form_ok']) ? 'visible' : ''; ?>"> <li id="info">There were some problems with your form submission:</li> <?php if(isset($cf['errors'])) { foreach($cf['errors'] as $error) { ?> <li><?php echo $error ?></li> <?php } ?> </ul> <form method="post" action="process.php"> <label for="name">Name: <span class="required">*</span></label> <input type="text" id="name" name="name" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['name'] : '' ?>" placeholder="John Doe" required autofocus /> <label for="email">Email Address: <span class="required">*</span></label> <input type="email" id="email" name="email" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['email'] : '' ?>" placeholder="johndoe@example.com" required /> <label for="telephone">Telephone: </label> <input type="tel" id="telephone" name="telephone" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['telephone'] : '' ?>" /> <label for="enquiry">Enquiry: </label> <select id="enquiry" name="enquiry"> <option value="General" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'General') ? "selected='selected'" : '' ?>>General</option> <option value="Sales" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'Sales') ? "selected='selected'" : '' ?>>Sales</option> <option value="Support" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'Support') ? "selected='selected'" : '' ?>>Support</option> </select> <label for="message">Message: <span class="required">*</span></label> <textarea id="message" name="message" placeholder="Your message must be greater than 20 charcters" required data-minlength="20"><?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['message'] : '' ?></textarea> <span id="loading"></span> <input type="submit" value="Holla!" id="submit-button" /> <p id="req-field-desc"><span class="required">*</span> indicates a required field</p> </form> <?php unset($_SESSION['cf_returndata']); ?> </div><?php } ?> PHP:
You left a brace open which caused unexpected end of file, so i added this last line to just clear up the error <?php } ?> PHP:
Try this, the original code is quite poor though, like @PoPSiCLe said you should learn to echo the HTML and not keep opening and closing PHP tags. <?php session_start(); //init variables $cf = array(); $sr = false; if(isset($_SESSION['cf_returndata'])){ $cf = $_SESSION['cf_returndata']; $sr = true; } ?> <!doctype html> <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Contact US</title> <meta name="description" content=""> <meta name="author" content=""> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="stylesheet" href="http://homer.pw/style.css"> <script src="js/libs/modernizr-1.7.min.js"></script> </head> <body> <div id="container"> <div id="contact-form" class="clearfix"> <h1>Get In Touch!</h1> <h2></h2> <?php //init variables $cf = array(); $sr = false; if(isset($_SESSION['cf_returndata'])){ $cf = $_SESSION['cf_returndata']; $sr = true; } ?> <ul id="errors" class="<?php echo ($sr && !$cf['form_ok']) ? 'visible' : ''; ?>"> <li id="info">There were some problems with your form submission:</li> <?php if(isset($cf['errors']) && count($cf['errors']) > 0) : foreach($cf['errors'] as $error) : ?> <li><?php echo $error ?></li> <?php endforeach; endif; ?> </ul> <form method="post" action="process.php"> <label for="name">Name: <span class="required">*</span></label> <input type="text" id="name" name="name" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['name'] : '' ?>" placeholder="John Doe" required autofocus /> <label for="email">Email Address: <span class="required">*</span></label> <input type="email" id="email" name="email" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['email'] : '' ?>" placeholder="johndoe@example.com" required /> <label for="telephone">Telephone: </label> <input type="tel" id="telephone" name="telephone" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['telephone'] : '' ?>" /> <label for="enquiry">Enquiry: </label> <select id="enquiry" name="enquiry"> <option value="General" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'General') ? "selected='selected'" : '' ?>>General</option> <option value="Sales" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'Sales') ? "selected='selected'" : '' ?>>Sales</option> <option value="Support" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'Support') ? "selected='selected'" : '' ?>>Support</option> </select> <label for="message">Message: <span class="required">*</span></label> <textarea id="message" name="message" placeholder="Your message must be greater than 20 charcters" required data-minlength="20"><?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['message'] : '' ?></textarea> <span id="loading"></span> <input type="submit" value="Holla!" id="submit-button" /> <p id="req-field-desc"><span class="required">*</span> indicates a required field</p> </form> <?php unset($_SESSION['cf_returndata']); ?> </div> </div> </body> </html> Code (markup):
Better code: <?php session_start(); $cf = (isset($_SESSION['cf_returndata'])) ? $_SESSION['cf_returndata'] : ''; $sr = (isset($_SESSION['cf_returndata'])) ? true : false; echo '<!DOCTYPE html> <head> <meta charset="utf-8"> <title>Contact US</title> <link rel="shortcut icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="stylesheet" href="http://homer.pw/style.css"> </head> <body> <div id="container"> <div id="contact-form"> <h1>Get in touch!</h1> <ul id="errors" class="'.(($sr && !$cf['form_ok']) ? 'visible' : '').'"> <li id="info">There were some problems with your form submission:</li>'; if (isset($cf['errors']) && count($cf['errors']) > 0) { foreach ($cf['errors'] as $error) { echo '<li>'.$error.'</li>'; } } echo ' </ul> <form method="post" action="process.php"> <label for="name">Name: <span class="required">*</span></label> <input type="text" id="name" name="name" value="'.(($sr && !$cf['form_ok']) ? $cf['posted_form_data']['name'] : '').'" placeholder="John Doe" required autofocus> <label for="email">Email Address: <span class="required">*</span></label> <input type="email" id="email" name="email" value="'.(($sr && !$cf['form_ok']) ? $cf['posted_form_data']['email'] : '').'" placeholder="johndoe@example.com" required> <label for="telephone">Telephone: </label> <input type="tel" id="telephone" name="telephone" value="'.(($sr && !$cf['form_ok']) ? $cf['posted_form_data']['telephone'] : '').'"> <label for="enquiry">Enquiry: </label> <select id="enquiry" name="enquiry">'; $optioncontent = array('General','Sales','Support'); foreach ($optioncontent as $value) { $selected = (!empty($cf['posted_form_data']['enquiry']) && $cf['posted_form_data']['enquiry'] == $value) ? 'selected="selected"' : ''; echo '<option value='.$value.'" '.$selected.'>'.$value.'</option>'; } echo ' </select> <label for="message">Message: <span class="required">*</span></label> <textarea id="message" name="message" placeholder="Your message must be greater than 20 charcters" required data-minlength="20">'.(($sr && !$cf['form_ok']) ? $cf['posted_form_data']['message'] : '').'</textarea> <span id="loading"></span> <input type="submit" value="Holla!" id="submit-button"> <p id="req-field-desc"><span class="required">*</span> indicates a required field</p> </form> </div> </div> </body> </html>'; PHP: (note, not tested, but should work) Instead of reassigning variables several times in the same file, you only need to do it once. Using session to provide errors... fine, albeit completely unnecessary, and you can unset the cf_returndata in the process.php
Don't you just love it when you help someone out and they don't even bother to say thanks, some people don't deserve any help..
Hey guys I apologize for the delay of my reply, I've been dealing with my family's cancer issue so I haven't had time to check back and forth. I really do appreciate it but I'm still having this huge error /: I just don't know how to make my Contact Form actually work like it's suppose to it seems like to me the guy created the original code completely screwed it up because I re-wrote some of it. But I'm still having an issue is it because it's a copy and paste error but the current issue with Popsicile's code is ABOVE BUT the error is Parse error: syntax error, unexpected '$cf' (T_VARIABLE) in /home********** on line 3 PHP:
I really have no idea what you are doing, I tested my solution and @PoPSiCLe's solution when it was posted and they both worked at the time.
You're doing something we're not aware of... Please post the exact code you're using. Including modifications you may have made.