Jump to content

Help showing form results on a new page PostPosted: Sun Oct 26, 2008 1:59 pm


dthomas31uk

Recommended Posts

I have a web page that I have created that allows a user to select info from database http://www.gostoke.eu/eu_home.php When the submit button is pressed the results are shown on the same page, but what I want to do is to display the results on a new page. Can anyone help???

 

Here is the code that handles the form information

<?php

include 'eu_home.php';

?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>

<title>Demo Multiple drop down list box from plus2net</title>

</head>



<body>

<?php
$pickup=$_POST['pickup'];

$cat=$_POST['cat'];

$subcat=$_POST['subcat'];

$load=$_POST['load'];

$appointment_date = sprintf('%02d-%02d-%04d',$_POST['day'], $_POST['month'], $_POST['year']); //mm-dd-yyyy

echo "Date required $appointment_date"."<BR>";

echo "Picking up from $pickup" ."<BR>";

echo "Going to $subcat"."<BR>";

$result = mysql_query("SELECT full_price, half_price, luton FROM eu_place WHERE city = '" . mysql_real_escape_string($subcat) . "'") or die(mysql_error());

$row = mysql_fetch_array($result);



switch($load) {

    case 'full_load' :

    $total = $row['full_price'];

    break;

    case 'half_load' :

    $total = $row['half_price'];

    break;

    case 'luton':

    $total = $row['luton'];

    break;
}

$rResult = mysql_query("SELECT price FROM uk_place WHERE city = '" . mysql_real_escape_string($pickup) . "'") or die(mysql_error());

while ($aRow = mysql_fetch_array($rResult, MYSQL_ASSOC))

{

    $iPrice = $aRow['price'];

    echo "£";

    echo ($iPrice) + ($total)."<BR>";

}

echo "<form method=post name=f2 action='confirm.php'>";

echo 'To confirm the above details, please enter your details below and click submit' . "<br />";

echo  'Full Name' . "<input type='text' name='name' id='name'/>" . "<br />";

echo  'Telephone Number' . "<input type='text' name='telephone' id='telephone'/>" . "<br />";

echo  'Email' . "<input type='text' name='email' id='email'/>" . "<br />";

echo 'Comments:' ."<textarea id='textareainput' name='textareainput' rows='10' cols='22'></textarea>";

echo "<input type='hidden' name='date' id='date' value='$appointment_date'/>";

echo "<input type='hidden' name='pickUpPoint' id='pickUpPoint' value='$pickup'/>";

echo "<input type='hidden' name='destination' id='destination' value='$subcat'/>";

echo "<input type='hidden' name='loadType' id='loadType' value='$load'/>";

echo "<input type='hidden' name='price' id='price' value='($iPrice) + ($total)'/>" . "<br />";

echo "<input type=submit value=Confirm>";
?>
</div>
</body>
</html>

You should use IF statements to set which code is displayed like so...

 

if(isset($_POST['submit'])){

$pickup=$_POST['pickup'];

$cat=$_POST['cat'];

$subcat=$_POST['subcat'];

$load=$_POST['load'];

$appointment_date = sprintf('%02d-%02d-%04d',$_POST['day'], $_POST['month'], $_POST['year']); //mm-dd-yyyy

echo "Date required $appointment_date"."<BR>";

echo "Picking up from $pickup" ."<BR>";

echo "Going to $subcat"."<BR>";

$result = mysql_query("SELECT full_price, half_price, luton FROM eu_place WHERE city = '" . mysql_real_escape_string($subcat) . "'") or die(mysql_error());

$row = mysql_fetch_array($result);



switch($load) {

    case 'full_load' :

    $total = $row['full_price'];

    break;

    case 'half_load' :

    $total = $row['half_price'];

    break;

    case 'luton':

    $total = $row['luton'];

    break;
}

$rResult = mysql_query("SELECT price FROM uk_place WHERE city = '" . mysql_real_escape_string($pickup) . "'") or die(mysql_error());

while ($aRow = mysql_fetch_array($rResult, MYSQL_ASSOC))

{

    $iPrice = $aRow['price'];

    echo "£";

    echo ($iPrice) + ($total)."<BR>";

}

echo "<form method=post name=f2 action='confirm.php'>";

echo 'To confirm the above details, please enter your details below and click submit' . "<br />";

echo  'Full Name' . "<input type='text' name='name' id='name'/>" . "<br />";

echo  'Telephone Number' . "<input type='text' name='telephone' id='telephone'/>" . "<br />";

echo  'Email' . "<input type='text' name='email' id='email'/>" . "<br />";

echo 'Comments:' ."<textarea id='textareainput' name='textareainput' rows='10' cols='22'></textarea>";

echo "<input type='hidden' name='date' id='date' value='$appointment_date'/>";

echo "<input type='hidden' name='pickUpPoint' id='pickUpPoint' value='$pickup'/>";

echo "<input type='hidden' name='destination' id='destination' value='$subcat'/>";

echo "<input type='hidden' name='loadType' id='loadType' value='$load'/>";

echo "<input type='hidden' name='price' id='price' value='($iPrice) + ($total)'/>" . "<br />";

echo "<input type=submit value=Confirm>";
}ELSE{

SHOW FORM FOR SELECTING OPTIONS;

}

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.