Jump to content

My code will not display the my account page???


cturner

Recommended Posts

When I test the following code it doesn't go the my account page as it should. Can someone please have a look at my code and tell me why it isn't going to the my account page? When I put information into the text boxes, etc and then I press the continue button it just refreshs the page. Thanks in advance. ???

[code=php:0]
if (isset($_POST['continue'])) {
$arrErrors = array();
// contact details
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$firstname1 = mysql_real_escape_string($_POST['firstname1']);
$lastname1 = mysql_real_escape_string($_POST['lastname1']);
$company1 = mysql_real_escape_string($_POST['company1']);
$address1 = mysql_real_escape_string($_POST['address1']);
$towncity1 = mysql_real_escape_string($_POST['towncity1']);
$state1 = mysql_real_escape_string($_POST['state1']);
$postcode1 = mysql_real_escape_string($_POST['postcode1']);
$country1 = mysql_real_escape_string($_POST['country1']);
$phone1 = mysql_real_escape_string($_POST['phone1']);
$email1 = mysql_real_escape_string($_POST['email1']);
// shipping details
$firstname2 = mysql_real_escape_string($_POST['firstname2']);
$lastname2 = mysql_real_escape_string($_POST['lastname2']);
$company2 = mysql_real_escape_string($_POST['company2']);
$address2 = mysql_real_escape_string($_POST['address2']);
$towncity2 = mysql_real_escape_string($_POST['towncity2']);
$state2 = mysql_real_escape_string($_POST['state2']);
$postcode2 = mysql_real_escape_string($_POST['postcode2']);
$country2 = mysql_real_escape_string($_POST['country2']);

$shippingmethod = mysql_real_escape_string($_POST['shippingmethod']);
$mailinglist = mysql_real_escape_string($_POST['mailinglist']);
$hearabout = mysql_real_escape_string($_POST['hearabout']);
$additional = mysql_real_escape_string($_POST['additional']);

// contact details
if ($username == '') {
$arrErrors['username'] = 'Please enter a username.';
}
if ($password == '') {
$arrErrors['password'] = 'Please enter a password.';
}
if ($firstname == '') {
$arrErrors['firstname'] = 'Please enter your first name.';
}
if ($lastname == '') {
$arrErrors['lastname'] = 'Please enter your last name.';
}
if ($address1 == '') {
$arrErrors['address1'] = 'Please enter your address.';
}
if ($towncity1 == '') {
$arrErrors['towncity1'] = 'Please enter the town or city where you live.';
}
if ($state1 == 'none') {
$arrErrors['state1'] = 'Please select the state where you live.';
}
if ($postcode1 == '') {
$arrErrors['postcode1'] = 'Please enter the postcode where you live.';
}
if ($country1 == 'none') {
$arrErrors['country1'] = 'Please select the country where you live.';
}
if ($phone1 == '') {
$arrErrors['phone1'] = 'Please enter your phone number.';
}
if ($email1 == '') {
$arrErrors['email1'] = 'Please enter your email address.';
}

// check to see if the username exists
$query = mysql_query("SELECT `user_username` FROM `tbl_users` WHERE `user_username` = '$username'") or die ("Could not query because: " . mysql_error());
$check = mysql_num_rows($query);
if ($check != 0) {
$arrErrors['username'] = "That username is already registered. Please choose another one.";
}

// check to see if the firstname and lastname exists
$query2 = mysql_query("SELECT `user_firstname`, `user_lastname` FROM `tbl_users` WHERE `user_firstname` = '$firstname' AND `user_lastname` = '$lastname'") or die ("Could not query because: " . mysql_error());
$check2 = mysql_num_rows($query2);
if ($check2 != 0) {
$arrErrors['firstname'] = "That first name is already registered.";
$arrErrors['lastname'] = "That last name is already registered.";
}

// if no errors add data to database and send details to Simply Stuck and continue on to the checkout
if (count($arrErrors) == 0) {
$date = time();
$date2 = date('j F Y', $date);
// add details to database
$sql = "INSERT INTO `tbl_users` (`userid`, `user_username`, `user_password`, `user_regdate`, `user_firstname`, `user_lastname`, `user_company`, `user_address`, `user_towncity`, `user_state`, `user_postcode`, `user_country`, `user_phone`, `user_email`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address`, `shipping_towncity`, `shipping_state`, `shipping_postcode`, `shipping_country`, `mailinglist`, `additional` VALUES ('0', '$username', '$password', '$date2', '$firstname1', '$lastname1', '$company1', '$address1', '$towncity1', '$state1', 'postcode1', 'country1', '$phone1, '$email1', '$firstname2', '$lastname', '$company2', '$address2', '$towncity', '$state2', '$postcode2', '$country2', '$mailinglist', '$additional')";

if (mysql_query($sql)) {
// send data to Simply Stuck's email address
$to = "[email protected]";
$subject = "New order from website";
$header = "From: $email1";
$message = "Contact Details\n"
."First Name: $firstname1\n"
."Last Name: $lastname1\n"
."Company: $company1\n"
."Address: $address1\n"
."Town/City: $towncity1\n"
."State: $state1\n"
."Postcode: $postcode1\n"
."Country: $country1\n"
."Phone: $phone1\n"
."E-mail: $email1\n\n"
."Shipping Details\n"
."Same as Contact Details: $sameas\n"
."First Name: $firstname2\n"
."Last Name: $lastname2\n"
."Company: $company2\n"
."Address: $address2\n"
."Town/City: $towncity2\n"
."State: $state2\n"
."Postcode: $postcode2\n"
."Country: $country\n"
."Shipping Method: $shippingmethod\n"
."Join our Mailing List: $mailinglist\n"
."How did you hear about us?: $hearabout\n"
."Order comments and special requests: $additional\n";
mail($to, $subject, $message, $header);

header ('Location: /my account/my account.php');
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $sql.</p>";
}
} else {
    // The error array had something in it. There was an error.
        // Start adding error text to an error string.
        $strError = '<div class="formerror"><p>Please check the following and try again:</p><ul>';
        // Get each error and add it to the error string
        // as a list item.
        foreach ($arrErrors as $error) {
            $strError .= "<li>$error</li>";
        }
        $strError .= '</ul></div>';
}
}
mysql_close();
[/code]
well if i were you i would check to see if the continue submit button is actually called continue. ie: <input type="submit" name="continue">
i would also place in echos then exits to see if it is reaching certain parts of the code. like. say. one after the error counting if statement. if you place one after that and it dosnt echo out then something is wrong above that. the if statement maybe wrong or something.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.