Jump to content

Recommended Posts

<?php
session_start();
$_SESSION["ic"] = $_POST["ic"];
$_SESSION["fullname"] = $_POST["fullname"];
$_SESSION["gender"] = $_POST["gender"];
$_SESSION["address"] = $_POST["address"];
$_SESSION["postcode"] = $_POST["postcode"];
$_SESSION["city"] = $_POST["city"];
$_SESSION["state"] = $_POST["state"];
$_SESSION["phonenumber"] = $_POST["phonenumber"];
$_SESSION["hpnumber"] = $_POST["hpnumber"];
$_SESSION["banktype"] = $_POST["banktype"];
$_SESSION["accname"] = $_POST["accname"];
$_SESSION["accnumber"] = $_POST["accnumber"];


//store data into  variable

$s01=$_SESSION["username"];
$s02=$_SESSION["password"];
$s03=$_SESSION["country"];

$s04=$_SESSION["ic"];
$s05=$_SESSION["fullname"];
$s06=$_SESSION["gender"];
$s07=$_SESSION["dob"];
$s08=$_SESSION["address"];
$s09=$_SESSION["postcode"];
$s10=$_SESSION["city"];
$s11=$_SESSION["state"];
$s12=$_SESSION["phonenumber"];
$s13=$_SESSION["hpnumber"];
$s14=$_SESSION["banktype"];
$s15=$_SESSION["accname"];
$s16=$_SESSION["accnumber"];


echo "s01=".$s01;
echo "s02=".$s02;
echo "s03=".$s03;
echo "s04=".$s04;
echo "s05=".$s05;
echo "s06=".$s06;
echo "s07=".$s07;
echo "s08=".$s08;
echo "s09=".$s09;
echo "s10=".$s10;
echo "s11=".$s11;
echo "s12=".$s12;
echo "s13=".$s13;
echo "s14=".$s14;
echo "s15=".$s15;
echo "s16=".$s16;







         


if(isset($_REQUEST['button']))
{
  
echo "clicked, thank you for your registration";
echo "testingIC ic=".$s04;
echo "username s=".$s01;


$con = mysql_connect("localhost","root","");
mysql_select_db("my_db", $con);

$sql = "CREATE TABLE person
(

	Username varchar(13),
	Password varchar(13),
	Country varchar(10),
	IC       varchar(13),
	FullName varchar(40),
	Gender varchar(15),
	DOB varchar(15),
	Address varchar(80),
	Postcode varchar(10),
	City varchar(20),
	State varchar(20),
	PhoneNumber varchar(15),
	HpNumber varchar(15),
	BankType varchar(30),
	AccName varchar(40),
	AccNumber varchar(15)
)";
mysql_query($sql,$con);

//insert into table
$sql="INSERT INTO person (Username,Password,Country,IC,FullName,Gender)
VALUES ('$s01','$s02','$s03','$s04','$s05','$s06')";


mysql_query($sql,$con);

}


?>


<html>
<body>

<form name='noname' action='register3.php' method=post>
<input type="submit" name='button' value='comfirm'>
</form>

</body>
</html>

 

those s04 until s16 initially will display the value

but after i click the "confirm" button then all those value become empty

and the data save in mysql also empty.

which s01-s03 is session data of form 1..

and s04-s16= session data of form2

and the above page is form3.

the sequence of form is like that.

i put  a echo "testingIC ic=".$s04;

inside the button's function coding to debug..after i click..it just show "testingIC ic= " there was nothing inside,  but the another  echo "username s=".$s01; showing the correct value..

anyone know where gone wrong? thanks..

 

 

Link to comment
https://forums.phpfreaks.com/topic/65583-solved-session-data-mysql-problem/
Share on other sites

see example ( have done ic & full name ) you just need the same with gender to accnumber

 

<?php
session_start();
if(isset($_POST["ic"]))
{
$_SESSION["ic"] = $_POST["ic"];
}
if(isset($_POST["fullname"]))
{
$_SESSION["fullname"] = $_POST["fullname"];
}
$_SESSION["gender"] = $_POST["gender"];
$_SESSION["address"] = $_POST["address"];
$_SESSION["postcode"] = $_POST["postcode"];
$_SESSION["city"] = $_POST["city"];
$_SESSION["state"] = $_POST["state"];
$_SESSION["phonenumber"] = $_POST["phonenumber"];
$_SESSION["hpnumber"] = $_POST["hpnumber"];
$_SESSION["banktype"] = $_POST["banktype"];
$_SESSION["accname"] = $_POST["accname"];
$_SESSION["accnumber"] = $_POST["accnumber"];

<?php
//just testing with this method  still need modify ..
session_start();
$_SESSION["username"] = $_POST["username"];
$_SESSION["password"] = $_POST["password"];
$_SESSION["country"] = $_POST["country"];
echo $_SESSION["country"];

?>


<html>

<body>
<form action="register3.php" method="post">
<table border="1">

<tr><td>IC Number:</td> <td> <input type="text" name="ic" /></td></tr>
<tr><td>Full name:</td> <td><input type="text" name="fullname"/></td></tr>
<tr><td>Gender</td><td>
<select name="gender">
<option value="male">Male</option>
<option value="female">Female</option>
</select>
</td></tr>

<tr><td>Date of Birth:</td> <td> <input type="text" name="dob" /></td></tr>
<tr><td>Address:</td><td> <input type="text" name="address" /></td></tr>
<tr><td>Postcode:</td><td> <input type="text" name="postcode" /></td></tr>
<tr><td>City:</td><td> <input type="text" name="city" /></td></tr>
<tr><td>State:</td><td> <input type="text" name="state" /></td></tr>
<tr><td>Phone Number:</td><td> <input type="text" name="phonenumber" /></td></tr>
<tr><td>H/P Number:</td><td><input type="text" name="hpnumber" /></td></tr>
<!--<tr><td>Bank type:</td><td> <input type="text" name="banktype" /></td></tr>-->

<tr><td>Bank Type:</td><td>
<select name="banktype">
<option value="maybank">Maybank</option>
<option value="publicbank">Public Bank</option>
<option value="rhb">Rhb</option>
<option value="hsbc">Hsbc</option>
</select>
</td></tr>

<tr><td>A/C Name:</td><td> <input type="text" name="accname" /></td></tr>
<tr><td>A/C Number</td><td> <input type="text" name="accnumber" /></td></tr>

<tr><td><input type="submit" value="Next"/></td></tr>
<tr><td><input type="reset" /></td></tr>


</table>

</form>


</body>

</html>

this is the form2 or the previous form where those form element/value located.

thanks.

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.