Click to See Complete Forum and Search --> : Form submission


clonmelog
01-30-2005, 04:43 PM
Hi,

I am creating a shopping cart with php and a mysql database here:

http://www.substanceabuseawareness.com/galasphp/mmcart/products.php

i have the value from the shopping cart carrying through to the point where the user can submit their personal details as you can see. I have these forms set to make sure valid data is entered with validation rules defined (see below).

My problem is coming with regard to how do i get the code to point the form to the next page and to allow the details to be written to our database? in the code below i have attempted this with javascript to go the the page "purchase-next.php". it doesnt work though as you can see.

code being used for enter.php:

<?php
session_start();
$total = $_SESSION['cost_of_last_cart']


?>

<?php
if ($submit || $submit_x) {

$isError = false;

if (strlen($C_Uname) < 3) {
$isError = true;
$error_C_Uname = "<img src='images/error.gif'>";

}
if(validate_email($C_Email)){
$isError = true;
$error_C_Email = "<img src='images/error.gif'>";

}
if (strlen($C_Fname) < 3) {
$isError = true;
$error_C_Fname = "<img src='images/error.gif'>";

}
if (strlen($C_Surname) < 3) {
$isError = true;
$error_C_Surname = "<img src='images/error.gif'>";

}
if (strlen($C_Yob) < 4) {
$isError = true;
$error_C_Yob = "<img src='images/error.gif'>";

}
if (strlen($C_Street) < 3) {
$isError = true;
$error_C_Street = "<img src='images/error.gif'>";

}
if (strlen($C_Street1) < 3) {
$isError = true;
$error_C_Street1 = "<img src='images/error.gif'>";

}
if (strlen($C_Town) < 3) {
$isError = true;
$error_C_Town = "<img src='images/error.gif'>";

}
if (strlen($C_City) < 3) {
$isError = true;
$error_C_City = "<img src='images/error.gif'>";

}
if (strlen($C_Phone) < 3) {
$isError = true;
$error_C_Phone = "<img src='images/error.gif'>";

}
if(!$isError){

//process form
session_register('C_Uname');
$_SESSION['username'] = "C_Uname";
session_register('C_Email');
$_SESSION['email'] = "C_email";
session_register('C_Fname');
$_SESSION['firstname'] = $C_Fname;
session_register('C_Surname');
$_SESSION['surname'] = $C_Surname;
session_register('C_Dob');
$_SESSION['dob'] = $C_Dob;
session_register('C_Mob');
$_SESSION['mob'] = $C_Mob;
session_register('C_Yob');
$_SESSION['yob'] = $C_Yob;
session_register('C_Street');
$_SESSION['street'] = $C_Street;
session_register('C_Street1');
$_SESSION['street1'] = $C_Street1;
session_register('C_Town');
$_SESSION['town'] = $C_Town;
session_register('C_City');
$_SESSION['city'] = $C_City;
session_register('C_Country');
$_SESSION['country'] = $C_Country;
session_register('C_Phone');
$_SESSION['phone'] = $C_Phone;

session_write_close();
redirect("purchase-next.php");



}

}


function redirect($url) {
echo '<script language="JavaScript">
document.location.href="' . $url . '"
</script>';
echo "If you do not get redirected <a href=\"" . $url . "\">click here</a>.";
}


(code for the rest is here but too long for me to post here. basically just has the textfields)


then the submit button:

<input type="image" src="images/ok.gif" align="absmiddle" border="0" name="submit">
</form></div>
</td>
</tr




Im lost on this one.....any help

thanks
clonmelog