SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 Which tag? I tried using the code in various ways: <?php error_reporting(-1); ini_set( 'display_errors', 'On' ); [email] if((isset($_POST['status']) && ($_POST['status']) == 'Active') { //REMAINDER OF CODE <?php error_reporting(-1); ini_set( 'display_errors', 'On' ); [email] if((isset($_POST["status"]) && ($_POST["status"]) == "Active") { //REMAINDER OF CODE both give the same errors, only difference is the ' ' as apposed to the " " Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 i have no idea why that if statement is an error >_< i can't see any errors or spelling mis-takes... so i have no idea. :/ Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 Wait... can you post the form that the below script drags the information from? Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 I originally had the post script running without the e-mail function and it was working fine. I then decided to add in the mail option, and at the begining it was working fine, except for on the odd occasion the user would get the e-mail but the data wouldn't be written to the database. Now I'm sitting with the scenario where I have moved the mail function to the end and all these other errors are poping up. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 i mean can you post the form that the values get the information, surely there is a form you have to fill out and click "submit" to get the mailing page? Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 Oh ok, here is the full code with the pages working together: <title> ? 2012 User Registration</title> <script type="text/javascript"> var count = 0; var delay = 250; var text = " 2012 User Registration "; function scroll () { document.title = text.substring(count, text.length) + text.substring (0, count) if (count < text.length) { count ++; } else { count = 1; } setTimeout ("scroll(1)", delay); } scroll(); </script> <LINK REL="SHORTCUT ICON" HREF="favicon.ico"> <script language = "Javascript"> function validateForm(form1) { if (document.form1.username.value == '') { alert('Please fill in your desired username'); return false; } if (document.form1.password.value == '') { alert('Please fill in your desired password!'); return false; } if (document.form1.verify_password.value == '') { alert('Please fill in your password again for confirmation!'); return false; } if (document.form1.password.value != document.form1.verify_password.value) { alert("The two passwords do not match! "+ "Please verify your password"); return false; } if (document.form1.fname.value == '') { alert('Please fill in your name!'); return false; } if (document.form1.lname.value == '') { alert('Please fill in surname!'); return false; } if (document.form1.sex.value == '') { alert('Please select your sex!'); return false; } } </script> <style type="text/css"> </style> </head> <link rel="stylesheet" type="text/css" href="css/layout_home.css"/> <body> <form id="form1" name="form1" method="post" action="submit/submit_register.php" onSubmit="return validateForm(form1);"> <table width="100%" border="0"> <tr> <td><strong> <!-- <h1 align="center">USER REGISTRATION</h1></strong></td>--> </tr> <tr> <td></td> <td> <br> <a class="tooltip" href="#">Why do we need all this information?<span class="custom info"> <img src="img\tooltips\info.png" alt="Information" height="48" width="48" /> <em>Information</em> This information is vital for us to keep all our systems up to date. It also allows us to gather information about you, should we need to get hold of someone in case of an emergency. <br><br> Please ensure that all information is captured accurately. </span> </a> </td> </tr> <tr> <td height="375"> </td> <td><table width="87%" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td><input type="hidden" name="status" align="left" valign="middle" value="Active"></td> </tr> <tr> <td width="29%" align="right" valign="left" ><strong>Username :</strong></td> <td><input type="text" name="username" align="left" valign="middle"></td> </tr> <tr> <td width="29%" align="right" valign="left" ><strong>Password :</strong></td> <td><input type="password" name="password" align="left" valign="middle"></td> </tr> <tr> <td width="29%" align="right" valign="left" ><strong>Verify Password :</strong></td> <td><input type="password" name="verify_password" align="left" valign="middle"></td> </tr> <tr> <td width="29%" align="right" valign="middle" ><strong>Title :</strong></td> <td width="71%" align="left" valign="middle"><select name="title" id="title"> <option value="">Select your Title</option> <option value="Miss">Miss</option> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Ms">Ms</option> </select></td> </tr> <!-- FIELD --> <tr> <td width="34%" align="right" valign="middle" ><strong>Name :</strong></td> <td> <input id="element_1_1" name= "fname" class="element text" maxlength="70" value="" /> <input id="element_1_2" name= "lname" class="element text" maxlength="70" value="" /> </td> <tr> <td></td> <td>First Name Last Name </td> </tr> <!-- FIELD --> <tr> <td width="34%" align="right" valign="middle" ><strong>Race :</strong></td> <td width="71%" align="left" valign="middle"><select name="race" id="race"> <option value="">Select your Race</option> <option value="African">African</option> <option value="Asian">Asian</option> <option value="Coloured">Coloured</option> <option value="White">White</option> </select></td> </tr> <!-- FIELD --> <tr> <td width="34%" align="right" valign="middle" ><strong>Sex :</strong></td> <td width="71%" align="left" valign="middle"><select name="sex" id="sex"> <option value="">Select your Sex</option> <option value="Female">Female</option> <option value="Male">Male</option> </select></td> </tr> <tr> <td width="29%" align="right" valign="middle" ><strong>Account Manager :</strong></td> <td width="71%" align="left" valign="middle"><select name="account_manager" id="account_manager"> <option value="">Select your Account Manager</option> <option value="Account Managers">Account Managers</option> </select></td> </tr> <tr> <td width="29%" align="right" valign="middle" ><strong>Department :</strong></td> <td width="71%" align="left" valign="middle"><select name="department" id="department"> <option value="">Select your Department</option> <option value="List OfDepartments">List Of Departments</option> </select></td> </tr> <tr> <td width="29%" align="right" valign="middle" ><strong>Designation :</strong></td> <td width="71%" align="left" valign="middle"><select name="designation" id="designation"> <option value="">Select your Designation</option> <option value="Manager">Manager</option> <option value="Supervisor">Supervisor</option> </select></td> </tr> <tr> <td width="29%" align="right" valign="middle" ><strong>Direct Report :</strong></td> <td width="71%" align="left" valign="middle"><select name="direct_report" id="direct_report"> <option value="">Select your Direct Report</option> <option value="List Of Reports">List Of Reports</option> </select></td> </tr> <tr> <td width="29%" align="right" valign="left" ><strong>ID Number :</strong></td> <td><input type="text" name="id_number" align="left" valign="middle" maxlength="13"></td> </tr> <tr> <td width="29%" align="right" valign="left" ><strong>MSISDN :</strong></td> <td><input type="text" name="number" align="left" valign="middle" maxlength="10"></td> </tr> <tr> <td width="29%" align="right" valign="left" ><strong>Alternative MSISDN :</strong></td> <td><input type="text" name="alt_number" align="left" valign="middle" maxlength="10"></td> </tr> <tr> <td width="34%" align="right" valign="middle" ><strong>E-Mail Address :</strong></td> <td> <input id="element_2_1" name="email" class="element text" size="45" maxlength="70" value=""/> </td> </tr> <tr> <td width="29%" align="right" valign="left" ><strong>Domain :</strong></td> <td><input type="text" name="domain" align="left" valign="middle" maxlength="80"></td> </tr> <!-- FIELD --> <tr> <td width="34%" align="right" valign="middle" ><strong>Next Of Kin :</strong></td> <td> <input id="element_1_1" name= "kin_fname" class="element text" maxlength="70" value=""/> <input id="element_1_2" name= "kin_lname" class="element text" maxlength="70" value=""/> </td> <tr> <td></td> <td>First Name Last Name </td> </tr> <tr> <td width="29%" align="right" valign="left" ><strong>Next Of Kin MSISDN :</strong></td> <td><input type="text" name="next_of_kin_number" align="left" valign="middle" maxlength="10"></td> </tr> <tr> <td> <p> <input type="reset" value="Reset Form"> </p></td> <td> <p> <input type="Submit" value="⇒ Register"> </p></td> </tr> </table></td> </tr> </table> </form> </body> </html> This was one of my first forms I created, so I have to admit that the coding is terrible. But it all worked so I never bothered to fix it. And then the actual code writing to the database: <?php error_reporting(-1); ini_set( 'display_errors', 'On' ); [email] if((isset($_POST['status']) && ($_POST['status']) == 'Active') { //Connect to DB server $con = mysql_connect("localhost","root","PW") or die("Could not connect: ".mysql_error()); $db = mysql_select_db("DB", $con) or die("Could not select database: ".mysql_error()); $sql="INSERT INTO userinfo (username , password , title , champ , race , sex , account_manager , department , designation , direct_report , id_number , number , alt_number , email , domain , next_of_kin , next_of_kin_number , status ) VALUES ('$_POST[username]' , '$_POST[password]' , '$_POST[title]' , '$_POST[fname] $_POST[lname]' , '$_POST[race]' , '$_POST[sex]' , '$_POST[account_manager]' , '$_POST[department]' , '$_POST[designation]' , '$_POST[direct_report]' , '$_POST[id_number]' , '$_POST[number]' , '$_POST[alt_number]' , '$_POST[email]' , '$_POST[domain]' , '$_POST[kin_fname] $_POST[kin_lname]' , '$_POST[next_of_kin_number]' , '$_POST[status]' )"; //Execute query $result = mysql_query($sql); if($result) { //Create email variable $to = "$_POST[email]"; $subject = "Registration - $_POST[username]"; $message = " Hi $_POST[fname] Thank you for completing your registration on the Call Tracker. You have registered using the following details: Username: $_POST[username] Password: $_POST[password] Name & Surname: $_POST[fname] $_POST[lname] E-Mail: $_POST[email] Should any of this information be incorrect, please contact the administrator. Welcome Aboard"; //Send email mail($to, $subject, $message); echo "<b><font color='white' face='segoe ui' size='2' align='center'>Congratulations you are a registered!</b></font>"; include "redirect_register.html"; } else { echo "Error: ".mysql_error(); } } else { echo "Error: ".mysql_error(); } [/email] ?> And thats the form. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 Im guessing the column in the database is named "Active", if so is the entry a word, or a number? and is it set to "A-I"? Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 The column in the database is called status. At the start of the form I have a hidden field name status and the value in this is set to Active. see the extract from the code below: <tr> <td><input type="hidden" name="status" align="left" valign="middle" value="Active"></td> </tr> Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 okay - the column in the database is it a number or a word? if its a number is it set to A-I? Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 I'm not sure I'm understanding what you asking, but the column in the table is set as VARCHAR. So it would be a word. The form is automatically selecting Active from the hidden field as the fields value is set to Active so that is the value that is being written to the table as well. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 I don't know then, sorry. Quote Link to comment Share on other sites More sharing options...
mikosiko Posted August 31, 2012 Share Posted August 31, 2012 count the open and closed parentheses in this line, and you should be able to figure out why are you getting the error if((isset($_POST['status']) && ($_POST['status']) == 'Active') { Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 I was about to get excited when I saw your reply Mikosiko, but when I removed the extra parenthesis I still get the same old error : Parse error: syntax error, unexpected 'if' (T_IF) in \submit_register.php on line 8 Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 all i can really suggest is to just try to find a different way of doing this, no one really knows why this error is appearing. and there doesnt seem to be anything wrong with the code, i was hoping that after you specifying whats in the database that it would just be a case of entering a small portion of code before the if statement, but it seems youve already included all of the compulsory data needed to complete the script. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 if you would like, when i go home later i can try and create my own version, and post it here and you just change it to suit what you need. i would also like to know if you know about "conf.php" and "$GLOBAL[' ']" settings? knowing about these might help make your php writing a lot easier. Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 Thanks Lily, I would really appreciate that. I'm still quite new to PHP and everything I know is really self taught. I've tried doing a lot of reading up on the various things as and when I need them, but as you can imagine, one can only read so much before your head starts hurting. And reading code makes your head hurt even more as everyone seems to have a bit of a different coding style if I can call it that. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 HAHA. I am self taught as well, i read up tutorials and things and definitions to try and give me a guideline. If you click on the little globe under my name youll be taken to a page im developing at the moment lol. Quote Link to comment Share on other sites More sharing options...
mikosiko Posted August 31, 2012 Share Posted August 31, 2012 I was about to get excited when I saw your reply Mikosiko, but when I removed the extra parenthesis I still get the same old error : Parse error: syntax error, unexpected 'if' (T_IF) in \submit_register.php on line 8 you didn't have to REMOVE one... you have to ADD one at the end. this is part of the code that you posted (see comments) [email] /// IS THIS TAG PART OF YOUR CODE OR JUST GARBAGE?... IF IT IS IN YOUR CODE REMOVE IT AND ALSO THE CLOSING TAG DOWN BELOW if((isset($_POST['status']) && ($_POST['status']) == 'Active') /// DON"T REMOVE a parenthesis ADD one ) by the end { Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 mikosiko - ive read what your saying and that won't make a difference as all the brackets are closed already - if anything it would probably just throw out yet another error. Quote Link to comment Share on other sites More sharing options...
mikosiko Posted August 31, 2012 Share Posted August 31, 2012 I do agree that the parenthesis doesn't make the difference (after the missing one was corrected), for me is just a matter of code style... what most likely is causing the T_IF error is the tag... assuming it IS IN the code as shown, and also assuming that the posted code is the whole code... otherwise the OP need to look for unmatched delimiters or missing closing semi-colons before the line that containing the if throwing the error Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 31, 2012 Share Posted August 31, 2012 mikosiko - ive read what your saying and that won't make a difference as all the brackets are closed already - if anything it would probably just throw out yet another error. No, they're not. Original code: if((isset($_POST['status']) && ($_POST['status']) == 'Active') { if( ( isset( $_POST['status'] ) && ( $_POST['status'] ) == 'Active' ) <- there should be a closing one to go with the if( right here. { Or remove the extra one after if( so it's if( isset( $_POST['status'] ) && ( $_POST['status'] ) == 'Active' ) { Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 Hi mikosiko, Yip, it is all the code. In one of my more recent posts on this thread, Lily had requested to see the form code as well which I then included. I have the . This was used as one of the very first recommendations on this thread. (Had to modify the email tag here as it links it. I didn't know it does that :-), so intentionally added and extra space). I really do appreciate everyone's input. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted August 31, 2012 Share Posted August 31, 2012 well in that case then you need to take the Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 Ok so it worked when removing the tags. Why did we put them in there in first place? Sorry I don't mean this question in sarcastic manner as I know it may seem like that, I'm asking for my understanding. The only thing to test now is to be sure that everything is being written to the database table before the user gets the e-mail. Here is the working code for anyone that might want it: <?php ini_set("display_errors", 1); error_reporting(-1); if(isset($_POST['status']) && ($_POST['status']) == 'Active') { //Connect to DB server $con = mysql_connect("localhost","root","password") or die("Could not connect: ".mysql_error()); $db = mysql_select_db("database", $con) or die("Could not select database: ".mysql_error()); $sql="INSERT INTO userinfo (username , password , title , champ , race , sex , account_manager , department , designation , direct_report , id_number , number , alt_number , email , domain , next_of_kin , next_of_kin_number , status ) VALUES ('$_POST[username]' , '$_POST[password]' , '$_POST[title]' , '$_POST[fname] $_POST[lname]' , '$_POST[race]' , '$_POST[sex]' , '$_POST[account_manager]' , '$_POST[department]' , '$_POST[designation]' , '$_POST[direct_report]' , '$_POST[id_number]' , '$_POST[number]' , '$_POST[alt_number]' , '$_POST[email]' , '$_POST[domain]' , '$_POST[kin_fname] $_POST[kin_lname]' , '$_POST[next_of_kin_number]' , '$_POST[status]' )"; //Execute query $result = mysql_query($sql); if($result) { //Create email variable $to = "$_POST[email]"; $subject = "Registration for $_POST[username]"; $message = " Hi $_POST[fname] Thank you for completing your registration on the Call Tracker. You have registered using the following details: Username: $_POST[username] Password: $_POST[password] Name & Surname: $_POST[fname] $_POST[lname] E-Mail: $_POST[email] Should any of this information be incorrect, please contact the Administrator. Welcome Aboard"; //Send email mail($to, $subject, $message); echo "<b><font color='white' face='segoe ui' size='2' align='center'>Congratulations you are registered!</b></font>"; include "redirect_register.html"; } else { echo "Error: ".mysql_error(); } } else { echo "Error: ".mysql_error(); } ?> Quote Link to comment Share on other sites More sharing options...
SalientAnimal Posted August 31, 2012 Author Share Posted August 31, 2012 I don't want to mark it as solved yet, just encase my data isn't always being written to the database just yet. Quote Link to comment 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.