I have a multi form...
I searched online and found this link...
http://www.html-form-guide.com/php-form/php-order-form.html

so i was doing a test, but it didnt work for me..
Can some1 help me, where i have gone wrong.
Here are my codes....

Form1.php

<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>form1</title>
</head>

<body>
<form method="post" action="form2.php">
    <p>
      <input type="text" name="sname">
  Name</p>
    <p>
      <input type="text" name="semail_address">
  Email</p>
    <p>
      <input type="submit" value="form 2">
            </p>
</form>
</body>
</html>

Form2.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form2</title>
</head>

<body>
<?php

//let's start the session
session_start();

//finally, let's store our posted values in the session variables
$_SESSION['name'] = $_POST['sname'];
$_SESSION['email_address'] = $_POST['semail_address'];
?>
<form method="post" action="form3.php">
	<p>
	  <input type="radio" value="Free" checked="checked" name="smembership_type">
  Free</p>
	<p>
	  <input type="radio" name="smembership_type" value="Normal">
  Normal</p>
	<p>
	  <input type="radio" name="smembership_type" value="Deluxe">
	  Deluxe</p>
	<p>
	  <input type="checkbox" name="sterms_and_conditions">
  I agreee</p>
	<p>
	  <label><a href="#" onclick="history.go(-1);return true;">BACK</a> </label>
	  <input type="submit" value="Form 3">
  </p>
</form>
</body>
</html>

Form 3.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form3</title>
</head>

<body>
<?php

//let's start the session
session_start();
$_SESSION['membership_type'] = $_POST['smembership_type'];
$_SESSION['terms_and_conditions'] = $_POST['sterms_and_conditions'];

?>
<form method="post" action="form_process.php">
  <p>Name on Card:
    <input type="text" name="sname_on_card">
  </p>
  <p>
    Credit card Number
    <input type="text" name="scredit_card_number">
  </p>
  <p>Expiry Date
    <input type="text" name="scredit_card_expiration_date">
  </p>
  <p>
	  <label><a href="#" onclick="history.go(-1);return true;">BACK</a> </label>
    <input type="submit" value="Finish">
        </p>
</form>

</body>
</html>

form_process.php

<?php session_start(); ?>
<?php
$db = "order";
$link = mysql_connect("localhost","root","");
if (!$link)
{
die("Couldn't connect to MySQL");
}

mysql_select_db("order",$link)
or die("Couldn't open $db: ".mysql_error($link));
//$_SESSION['name'] = $_POST['name'];
//$_SESSION['email_address'] = $_POST['email_address'];
//$_SESSION['membership_type'] = $_POST['membership_type'];
//$_SESSION['terms_and_conditions'] = $_POST['terms_and_conditions'];
$_SESSION['name_on_card'] = $_POST['sname_on_card'];
$_SESSION['credit_card_number'] = $_POST['scredit_card_number'];
$_SESSION['credit_card_expiration_date'] = $_POST['scredit_card_expiration_date'];
?>
<?php	
//let's create the query
$query = "INSERT into subscriptions(name,email_address,membership_type,terms_and_conditions,name_on_card, credit_card_number, credit_card_expiration_date)".
		"VALUES(" . $_SESSION['name'] . ", 
				" . $_SESSION['email_address'] . ",
				" . $_SESSION['membership_type'] . ",
				" . $_SESSION['terms_and_conditions'] . ",
				" . $_SESSION['name_on_card'] . ",
				" . $_SESSION['credit_card_number'] . ",
				" . $_SESSION['credit_card_expiration_date'] . ")";
mysql_query($query,$link)
					or die("Couldn't add data to add to \"Report Form\" table: 
".mysql_error($link));

				mysql_close($link);
				?>

and my database Table is:

create table subscriptions
(name varchar(30),
email_address varchar(30),
membership_type varchar(15),
terms_and_conditions varchar(30),
name_on_card varchar(30),
credit_card_number INT(15),
credit_card_expiration_date DATE
);

The error that i get is:

Couldn't add data to add to "Report Form" table: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on, Kumar, 21355346, 2010.12.23)' at line 4

Can some1, point me where i am going wrong..
Pls help...
thanks...

problem is on expirtion date which you are entering value in text field. give 0000-00-00 this format.

#
<p>Expiry Date

<input type="text" name="scredit_card_expiration_date">

</p>

problem is on expirtion date which you are entering value in text field. give 0000-00-00 this format.

#
<p>Expiry Date

<input type="text" name="scredit_card_expiration_date">

</p>

Hi kalpana,

I tried deleting the expiration date field and tested...Its still the same problem...

From form2.php:

<input type="checkbox" name="sterms_and_conditions">

Do you think it might need a value in there?

The problem is with your MySQL. Try quoting the values you are inserting. Also, on a side note, instead of using session you could use hidden inputs to pass the required values to form_process.php. Though it won't make much of a difference, substituting another technique in place of session saves you some (Very little, except on servers that serve millions of users) space since values are stored on the server.
One other thing: Why are you passing the value of a terms and conditions box to MySQL? It seems unnecessary since if the user doesn't agree to the TOS, then they won't be added, but again, your choice.

EDIT:
While I think about it: It looks like you are handling credit card numbers in your script. If I'm not mistaken, it is illegal in most countries to transmit a credit card number over HTTP. Are you using HTTPS?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.