By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,349 Members | 1,353 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,349 IT Pros & Developers. It's quick & easy.

how to save data and at the same time redirect to another page with the data in php

P: 35
hi i just wanna know if it is possible to save data in mysql and at the same time redirect it to another page with the data in php..(note: i know how to save the data but i can't find a way to drag that data to another page)
May 3 '12 #1
Share this Question
Share on Google+
4 Replies


100+
P: 1,059
follow this example below:
Expand|Select|Wrap|Line Numbers
  1. $eample_data='something';
  2. /*
  3. statements to save data;
  4.  
  5. */
  6.  
  7. header("Location: destination.php?example_data=".$eample_data);
  8.  
May 3 '12 #2

P: 35
hi johny thanks for the rply but can u be more specific im still just starting to learn php and most of it i still dont know..uhm where am i going to put this code? this is may code for saving..thanks



<?php
$rnum=$_GET['txtrnum'];
$pday=$_GET['txtpday'];
$pmonth=$_GET['txtpmonth'];
$phr=$_GET['txtphr'];
$pmin =$_GET['txtpmin'];
$rday =$_GET['txtrday'];
$rmonth =$_GET['txtrmonth'];
$rhr =$_GET['txtrhr'];
$rmin =$_GET['txtrmin'];
$origin =$_GET['txtorigin'];
$destination =$_GET['txtdestination'];
$vehicle =$_GET['txtvehicle'];
$fname =$_GET['txtfname'];
$lname =$_GET['txtlname'];
$email =$_GET['txtemail'];
$contact =$_GET['txtcontact'];
$address =$_GET['txtaddress'];
$zip =$_GET['txtzip'];
$city =$_GET['txtcity'];
$country =$_GET['txtcountry'];
$rate=$_GET['txtrate'];


$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'msic';
mysql_select_db($dbname);




$sql="INSERT INTO sd (Rnum, Pickday, Pickmonth, Pickhour, Pickmin, Rday, Rmonth, Rhour, Rmin, Origin, Destination, Vehicle, Fname, Lname, Email, Contact, Address, Zip, City, Country, Rate)
VALUES ('".$_POST['txtrnum']."','".$_POST['txtpday']."','".$_POST['txtpmonth']."','".$_POST['txtphr']."','".$_POST['txtpmin']."','".$_POST['txtrday']."','".$_POST['txtrmonth']."','".$_POST['txtrhr']."','".$_POST['txtrmin']."', '".$_POST['txtorigin']."' , '".$_POST['txtdestination']."', '".$_POST['txtvehicle']."', '".$_POST['txtfname']."', '".$_POST['txtlname']."', '".$_POST['txtemail']."', '".$_POST['txtcontact']."', '".$_POST['txtaddress']."', '".$_POST['txtzip']."','".$_POST['txtcity']."', '".$_POST['txtcountry']."','".$_POST['txtrate']."')";

if (!mysql_query($sql,$conn))
{
die('Error: ' . mysql_error());
}
/*THIS IS THE PART THAT I WANT TO BE REDIRECTED WITH THE DATA THAT I SAVE IN MYSQL*/

header("location:http://localhost/msicrevised/europcar/PaymentForm.php");


mysql_close($conn)

?>
May 3 '12 #3

100+
P: 1,059
I was specific with my answer, read again
May 3 '12 #4

P: 35
@johny10151981
okay i got it thanks..
May 3 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.