Jump to content

script not working correctly


aebstract

Recommended Posts

Basically, the top of the script is what we're looking at. If you're not logged in, you get taken to the login screen and if you've already filled this form out, you get taken back to the main page of the site. Right now, it's taking everyone to the main page, even if they haven't filled it out. I don't really see why though? There are 2 rows in my table right now.

 

 

<?php
if ($user->data['user_id'] == ANONYMOUS)
{
header("Location: forums/ucp.php?mode=login");
exit;
}

$query = mysql_query("SELECT * FROM registrations WHERE userid = '$user->data[user_id]'") or DIE(mysql_error());
if(mysql_num_rows($query)!=0){
	while($r=mysql_fetch_array($query))
	{
header("Location: index.php");
exit;
}
}

if (isset($_POST['submit'])){


if (empty ($_POST['firstname'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['lastname'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['address'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['city'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['state'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['zip'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['phone1'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['phone2'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['phone3'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['classdropdown'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif ($_POST['classdropdown'] == Classes) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['carnumber'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['makemodel'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
} elseif (empty ($_POST['email'])) {
$problem = TRUE;
$error .= 'All fields are required to be fully filled out.';
}




	if (!$problem) {




$query = mysql_query("INSERT INTO registrations (firstname, lastname, address, city, state, zip, email, phone, number, car, class)
VALUES ('$_POST[firstname]', '$_POST[lastname]', '$_POST[address]', '$_POST[city]', '$_POST[state]', '$_POST[zip]', '$_POST[email]', '$_POST[phone1]$_POST[phone2]$_POST[phone3]', '$_POST[carnumber]', '$_POST[makemodel]', '$_POST[classdropdown]')") or DIE(mysql_error());

$lastid = mysql_insert_id();

$query = mysql_query("INSERT INTO standings (memberid, year)
VALUES ('$lastid', '2010')") or DIE(mysql_error());









	$emailbody = "
ORSCA REGISTRATION FORM<br /><br />

<table>
<tr>
<td>
Name:
</td><td>
</td><td>
$_POST[firstname] $_POST[lastname]
</td></tr>
<tr><td>
Email:
</td><td>
</td><td>
$_POST[email]
</td></tr>
<tr><td>
Phone Number:
</td><td>
</td><td>
($_POST[phone1]) $_POST[phone2] - $_POST[phone3]
</td></tr>
</table>

$_POST[address]<br />
$_POST[city], $_POST[state] $_POST[zip]<br /><br />

$_POST[makemodel]<br />
$_POST[classdropdown]<br />
$_POST[carnumber]

	";






	$to  = 'tcantwell@berryequipment.net' . ', '; // note the comma

	// subject
	$subject = 'ORSCA Registration Form';

	// message
	$message = "
	<html>
	<head>
	</head>
	<body>
	$emailbody
	</body>
	</html>
	";

	// To send HTML mail, the Content-type header must be set
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

	// Additional headers

	// Mail it
	mail($to, $subject, $message);




        }


}













$content .= "
<div id=\"content\">
<h3>Season Registration Form</h3>
<p>You will appear on the standings page AFTER your registration information has been received and confirmed. If you notice any information that is wrong and needs to be changed, <a href=\"forums/ucp.php?i=pm&mode=compose&u=2\">click here to send a message to the ADMIN</a> with a request of changed information.</p>
<h3>Registration Fees</h3>

<p>
Registration is $125 per year or $25 per event
<br /><br />
You can mail check or money order to:
<br /><br />
ORSCA<br />
2732 Oakwood Drive<br />
Loganville, GA 30052

</p>
";


if (isset($error)) {
$content .= "<h2>Error:<br /> $error</h2>";
}

$content .= "<form action=\"index.php?page=registration\" method=\"post\" name=\"registration\">
<table><tr><td class=\"rtable1\">
Name:
</td><td class=\"tablespace\">
</td><td>
<input type=\"text\" maxlength=\"20\" class=\"textfield\" name=\"firstname\" value=\"$_POST[firstname]\" size=\"7\" /> <input type=\"text\" maxlength=\"20\" class=\"textfield\" name=\"lastname\" value=\"$_POST[lastname]\" size=\"10\" />
</td></tr>
<tr><td class=\"rtable1\">
Address:
</td><td class=\"tablespace\">
</td><td>
<input type=\"text\" maxlength=\"60\" class=\"textfield\" name=\"address\" value=\"$_POST[address]\" size=\"20\" /><br />
</td></tr>
<tr><td class=\"rtable1\">
City, State, Zip:
</td><td class=\"tablespace\">
</td><td>
<input type=\"text\" maxlength=\"30\" class=\"textfield\" name=\"city\" value=\"$_POST[city]\" size=\"10\" />, <input type=\"text\" maxlength=\"2\" class=\"textfield\" style=\"text-transform: uppercase; text-align:center;\" name=\"state\" value=\"$_POST[state]\" size=\"1\" /> <input type=\"text\" maxlength=\"5\" class=\"textfield\" style=\"text-align: center;\" name=\"zip\" value=\"$_POST[zip]\" size=\"2\" />
</td></tr>



<tr><td class=\"rtable1\">
Phone Number:
</td><td class=\"tablespace\">
</td><td>
<input type=\"text\" maxlength=\"3\" class=\"textfieldp\" name=\"phone1\" value=\"$_POST[phone1]\" size=\"1\" /><input type=\"text\" maxlength=\"3\" class=\"textfieldp\" name=\"phone2\" value=\"$_POST[phone2]\" size=\"1\" /><input type=\"text\" maxlength=\"4\" class=\"textfieldp\" name=\"phone3\" value=\"$_POST[phone3]\" size=\"2\" />
</td></tr>
<tr><td class=\"rtable1\">
Racing Class:
</td><td class=\"tablespace\">
</td><td>
<select name=\"classdropdown\">
  <option style=\"text-align: center; border-bottom: 1px solid #000; margin-bottom: 10px; padding-bottom: 5px;\">Classes</option>
  <option value=\"Outlaw 10.5\">Outlaw 10.5</option>
  <option value=\"Limited Street\">Limited Street</option>
  <option value=\"EZ Street\">EZ Street</option>
  <option value=\"Real Street\">Real Street</option>
  <option value=\"Modified Street\">Modified Street</option>
  <option value=\"4.70 Index\">4.70 Index</option>
  <option value=\"5.30 Index\">5.30 Index</option>
  <option value=\"6.00 Index\">6.00 Index</option>
  <option value=\"7.00 Index\">7.00 Index</option>
</select>
</td></tr>
<tr><td class=\"rtable1\">
Desired Car Number:
</td><td class=\"tablespace\">
</td><td>
<input type=\"text\" maxlength=\"10\" class=\"textfield\" name=\"carnumber\" value=\"$_POST[carnumber]\" size=\"5\" />
</td></tr>
<tr><td class=\"rtable1\">
Vehicle Make/Model:
</td><td class=\"tablespace\">
</td><td>
<input type=\"text\" maxlength=\"50\" class=\"textfield\" name=\"makemodel\" value=\"$_POST[makemodel]\" size=\"20\" />
</td></tr>
<tr><td class=\"rtable1\">
Email Address:
</td><td class=\"tablespace\">
</td><td>
<input type=\"text\" maxlength=\"50\" class=\"textfield\" name=\"email\" value=\"$_POST[email]\" size=\"30\" />
</td></tr>
</table>
<input type=\"submit\" name=\"submit\" class=\"textfield\" value=\"Send Registration\" />

</form>

</div>

";


?>

 

 

EDIT: Oh, and the first part works, if you're not logged in it takes you to the login page. Other than that you're getting booted to home page.

Link to comment
Share on other sites

It's a part of a phpbb integration thing, so it's in their includes and whatnot. I echo'd out that user_id and it gave the correct one, so that isn't the problem for sure.

 

What I just found: In my database, the 2nd row was where a user submitted the registration, but it entered his user_id as 0 instead of 1331 which is what it was. I manually changed the 0 to 1331 and now the registration page allows you to see it if you haven't filled it out. What's up with that?

Link to comment
Share on other sites

No idea what your talking about.

 

Well, maybe read what I said? A user submitted the form, it entered 0 for his user_id when it is actually 1331. Then, everyone trying to get there got sent to index.php via the top section. When I changed the 0 to a 1331 in the database, it opened back up and allowed users to access it. I don't know how you want me to explain that any other way...

Link to comment
Share on other sites

Can you at least narrow the code down to what is related then instead of simply dumping code on the forum? The code you have posted has multiple queries, no indentation consistence and is quite frankly difficult to read.

Link to comment
Share on other sites

It's 2 things at the top that direct you correctly. A couple if statements to see if the form was all submitted. The query for that form and then the form.

 

 

Anyway, another user submitted the form and it entered a 0 for their user_id.

Here is really the only query (except for checking the db at the top):


$query = mysql_query("INSERT INTO registrations (firstname, lastname, address, city, state, zip, email, phone, number, car, class)
VALUES ('$_POST[firstname]', '$_POST[lastname]', '$_POST[address]', '$_POST[city]', '$_POST[state]', '$_POST[zip]', '$_POST[email]', '$_POST[phone1]$_POST[phone2]$_POST[phone3]', '$_POST[carnumber]', '$_POST[makemodel]', '$_POST[classdropdown]')") or DIE(mysql_error());

$lastid = mysql_insert_id();

$query = mysql_query("INSERT INTO standings (memberid, year)
VALUES ('$lastid', '2010')") or DIE(mysql_error());

 

Link to comment
Share on other sites

Anyway, another user submitted the form and it entered a 0 for their user_id.

 

That query does not touch any user_id field so I assume it should be set to auto increment? Is it actually set to auto increment?

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.