473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to fix: Parse error: syntax error, unexpected T_IF

Creating a registration form and am getting a parse error on the line in the html form code for email address?!

Any thoughts please.

Expand|Select|Wrap|Line Numbers
  1. // Check for a first name:
  2.     if (empty($_POST['first_name'])) {
  3.     $errors[]='You forgot to enter your first name.';
  4.     } else {
  5.     $fn = trim($_POST['first_name']);
  6.     }
  7.  
  8.     // Check for a last name:
  9.     if (empty($_POST['last_name'])) {
  10.     $errors[]='You forgot to enter your last name.';
  11.     } else {
  12.     $ln = trim($_POST['last_name']);
  13.     }
  14.  
  15.     // Check for an email address:
  16.     if (empty($_POST['email'])) {
  17.     $errors[]='You forgot to enter your email address.';
  18.     } else {
  19.     $e = trim($_POST['email']);
  20.     }
  21.  
  22.     // Check for a password and match against the confirmed password:
  23.     if (!empty($_POST['pass1'])) {
  24.     if ($_POST['pass1'] != $_POST['pass2']) {
  25.     $errors[]='Your password did not match the confirmed password.';
  26.     } else { 
  27.     $p = trim($_POST['pass1']);
  28.     }
  29.     } else {
  30.     $errors[]='You forgot to enter your password.';
  31.     }
  32.  
  33.     if (empty($errors)) { // If everything's OK.
  34.  
  35.     // Register the user in the database...
  36.  
  37.     // Make the query:
  38.     $q = "INSERT INTO users (first_name, last_name, email, pass, registration_date) VALUES ('$fn', '$ln', '$e', SHA1('$p'), NOW() )";
  39.     $r = @mysqli_query ($dbc, $q); // Run the query.
  40.     if ($r) { // If it ran OK.
  41.  
  42.     // Print a message.
  43.     echo '<h1>Welcome</h1>
  44.     <p>You are now registered. Login and challenge!</p>';
  45.  
  46.     } else { // If it did not run OK.
  47.  
  48.     // Public message:
  49.     echo '</h1>System Error</h1>
  50.     <p class="error">You could not be registered due to a system error. We apologise for any inconvenience.</p>';
  51.  
  52.     // Debugging message:
  53.     echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>';
  54.  
  55.     } // End of if ($r) IF.
  56.  
  57.  
  58.     // Include the footer and quit the script:
  59.     include ('includes/footer.html');
  60.     exit();
  61.  
  62.     } else { // Report the errors.
  63.  
  64.     echo '<h1>Error!</h1>
  65.     <p class="error">The following error(s) occurred:<br />';
  66.     foreach ($errors as $msg) { // Print each error.
  67.     echo " - $msg<br />\n";
  68.     }
  69.     echo '</p><p>Please try again.</p><p><br /></p>';
  70.  
  71.     } // End of if (empty($errors)) IF.
  72.     mysqli_close($dbc); // Close the database connection.
  73.  
  74.     } // End of the main Submit conditional.
  75.     ?>
  76.     <h2><span style="color: #444444; font-weight: normal; letter-spacing: normal; font-size: 19px; line-height: 20px">Registration Form</span><br />
  77. </h2>        
  78. <form action="registration.php" method="post" id="registrationform">        
  79. <p>Registration</p>
  80. <p> <label for="first_name">First Name:</label> <input id="first_name" name="first_name" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" type="text" size="10" maxlength="20" tabindex="1" /></p>
  81. <p> <label for="last_name">Last Name:</label> <input id="last_name" name="last_name" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" type="text" size="10" maxlength="20" tabindex="1" /></p>
  82. <p> <label for="email">Email Address:</label>  <input id="email" name="email" value="<? php if (isset($_POST['email'])) echo $_POST['email']; ?>" type="text" size="20" maxlength="40" tabindex="1" /></p>
  83. <p> <label for="pass1">Password:</label> <input id="pass1" name="pass1" value="" type="password" size="10" maxlength="20" tabindex="1" /></p>
  84. <p> <label for="pass2">Confirm Password:</label> <input id="pass2" name="pass2" value="" type="password" size="10" maxlength="20" tabindex="1" /></p>
  85. <p class="no-border"><input class="button" type="submit" value="Submit" tabindex="5" /></p>
  86. <input type="hidden" name="submitted" value="TRUE" />
  87. </form>
  88.  
Nov 2 '10 #1
1 2773
Dormilich
8,658 Expert Mod 8TB
which line does the error refer to?
Nov 2 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
36
by: rhys | last post by:
My Gurus and Angels -- Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My...
3
by: SilvaZodiac | last post by:
Hi everyone, I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the...
5
praclarush
by: praclarush | last post by:
I've just started php, and this is a class assignment, but my question is I’m getting this error PHP Parse error: syntax error, unexpected T_IF, expecting T_VARIABLE or '$' in...
2
by: fburn | last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux. I receive an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or...
9
akohistani
by: akohistani | last post by:
I am having Parse error problem with my newly purchased Php upload script I have uploaded the script and I get the error below Parse error: syntax error, unexpected $end in URL/functions.php on...
3
paulrajj
by: paulrajj | last post by:
hi to all, i am getting syntax error on my code.. Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in D:\xampp\htdocs\Dummy\paulraj\matrim\exam.php on line 62 ...
10
by: benicio | last post by:
Parse error: syntax error, unexpected T_STRING, expecting '(' in C:\wamp\www\study_group\includes\functions.php on line 19 I got this error and this syntax is from 8 to 19th line. <?php ...
3
by: brkseven | last post by:
Looking for help with this Contact Form. The error is on line 1, but that' doesn't mean a lot, I think. In fact, a php syntax check passed it, but I was hoping for an easy syntax error, it looks...
4
by: 9139530 | last post by:
Hey, I'm getting the error: Parse error: syntax error, unexpected T_VARIABLE in Z:\home\baza\www\get2.php on line 7 with this code (have 2 pages , html-from page (reguser.php) and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.