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>

Link to comment
Share on other sites

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;

}

Link to comment
Share on other sites

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.