Jump to content

What is going wrong here?


SalientAnimal

Recommended Posts

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 " "

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

{

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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'
)
{

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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();
}



?> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.