473,544 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 2787
Dormilich
8,658 Recognized Expert Moderator Expert
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
46166
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 where the inital " started? I find myself adding /* */ blocks or cutting/pasting sections of code out in order to find where the error occured. ...
36
7960
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 shortcomings will soon become apparent. I am developing an estimating construction system, using PHP5 and MySQL 5.0.24a with Ubuntu. I have a main...
3
6936
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 offending line, but being amateur, I don't know where. I've tried putting one in several places, to no avail. Clearly, to solve this in a smaller...
5
10013
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 C:\wamp\www\ssp\SSP04\guessingGame.php on line 42. Iíve tried to make sense of it but Iím at a lose, there error is referring to this segment of the code. else{...
2
3226
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 T_VARIABLE or T_NUM_STRING in /var/www/html/inventoryControl/supplier.php on line 26 (line number changed to match code tags) The code is as follows: ...
9
3518
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 line 400 Someone please help me I contacted the owner of the script where I purchased he is not replying me I bought it from...
3
5589
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 what's the actual problem here..? my code
10
5632
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 $subject_set = get_all_subjects(); while ($subject = mysql_fetch_array($subject_set)) { echo...
3
5176
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 more complicated now. Anyway, here's the error: "Parse error: syntax error, unexpected T_VARIABLE in...
4
3378
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 php(get2.php))work with mysql retuser.php <br><a href='security.php'>Вернуться</a> <form action="get2.php" method="POST"> <table>
0
7373
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7389
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7717
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5306
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3427
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1848
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.