Jump to content

[SOLVED] Displaying manipulated user entered data (via a html form) using PHP


davewit13

Recommended Posts

Hi guys,

 

First time using this site. And quiet new to php/server side scripts, so might be a easy one i dunno.

 

Basically i have a html form with drop downs etc. and im sending this to a php file. At the moment i just want to store the values in variable and display them to the screen before manipulating them (which should be the easy bit, i think!).

 

While i do see the information set in the html form on the address bar on the next screen, i cant seem to do 

 

At the moment heres how it looks:

 

<html>

........

<form name="myform"  method="get" action="domestic.php">

.......

<td align="right" colspan="2"><input name="Submit" type="submit" value="Submit"/>

<input type="reset" name ="reset" value="Reset" /></td>

</form>

....</html>

 

domestic.php looks like:

<?php

$FullPallet=$_GET["FullPallet"]

$QuarterPallet=$_GET["QuarterPallet"]

$DeliveryType=$_GET["DeliveryType"]

$DeliveryFrom=$_GET["DeliveryFrom"]

$DeliveryTo=$_GET["DeliveryTo"]

?>

<html>

......

Hello, You have queried an order of <?php echo $FullPallet ?> full pallets and <?php echo $QuarterPallet; ?> quarter pallets. The delivery is from  <?php $DeliveryFrom ?> and is going to <?php $DeliveryTo ?>. This is a <?php $HTTP_GET_VARS['DeliveryType'] ?> delivery.

.....

</html>

 

 

As you can see to display it to the screen i have tried quiet a few different things, not sure if thats the problem or how i set the variables etc.

 

Please Help!!

Link to comment
Share on other sites

@Aravinthan...why would you want to put quotes around variables?

 

---------------------------------------

In your php code at the top of the page it is missing the line termination symbol of semi-colon--------> ;

 

* Your page code be crashing... a lot of hosting companies turn off errors for some reason????

 

Your code should be:

<?php
$FullPallet=$_GET["FullPallet"];
$QuarterPallet=$_GET["QuarterPallet"];
$DeliveryType=$_GET["DeliveryType"];
$DeliveryFrom=$_GET["DeliveryFrom"];
$DeliveryTo=$_GET["DeliveryTo"];
?>

 

other than that your code looks correct...what is the page doing exactly...does it print the text but just not the variable values?

Link to comment
Share on other sites

I'm not sure what you mean. Do you want to NOT display the 'you have ordered.....' part unless they actually do?

 

<?php
$FullPallet=$_POST["FullPallet"];
$QuarterPallet=$_POST["QuarterPallet"];
$DeliveryType=$_POST["DeliveryType"];
$DeliveryFrom=$_POST["DeliveryFrom"];
$DeliveryTo=$_POST["DeliveryTo"];
?>

You should put them in a POST to void user modification.. htmlspecialchar is smart to.. unless you want the user to be able to change something in the GET requests and mess with the order..

<form name="myform"  method="POST" action="domestic.php">

 

And simply..

if (isset($_POST['FullPallet'])){ 
   echo "Hello, You have queried an order of $FullPallet full pallets and $QuarterPallet  quarter pallets. The delivery is from $DeliveryFrom and is going to $DeliveryTo. This is a ".$HTTP_GET_VARS['DeliveryType']."delivery."
} else {
  echo "Pleas enter form.";
}

 

Link to comment
Share on other sites

I have put the semi colon in, however it doesnt seem to display anything back to the screen from my php code. This is in the domestic.php part.

 

<table width="100%" height="400" border="0"  align ="left"cellpadding="0" cellspacing="0" background="Globe.jpg">

"Hello, You have queried an order of

<?php echo "Hello, You have queried an order of $FullPallet full pallets and $QuarterPallet  quarter pallets. The delivery is from $DeliveryFrom and is going to $DeliveryTo. This is a ".$HTTP_GET_VARS['DeliveryType']."delivery."?>

hi test <?php echo php test "quote test" ?>

</table>

 

However the page does not display anything. only the "hello you have queries an order of, and te hi test part also. It seems to ignore anything in the <?php... ?>

Link to comment
Share on other sites

Domestic.php

 

<?php
$FullPallet=$_GET["FullPallet"];
$QuarterPallet=$_GET["QuarterPallet"];
$DeliveryType=$_GET["DeliveryType"];
$DeliveryFrom=$_GET["DeliveryFrom"];
$DeliveryTo=$_GET["DeliveryTo"];

?>
<html>
<head>
<title>Domestic Quote Result</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="mm_health_nutr.css" type="text/css" />
<script language="JavaScript" type="text/javascript">
var d=new Date();
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
var FullPallet= frm.FullPallet.value
var QuarterPallet=frm.QuarterPallet.value
var DeliveryType= frm.Delivery.value
var DeliveryFrom=frm.DeliveryFrom.value
var DeliveryTo=frm.DeliveryTo.value
</script>
<style type="text/css">
<!--
.style2 {color: #FFFFFF}
.style7 {color: #000000; font-weight: bold; font-size: 36px; }
.style10 {color: #993300; font-weight: bold; font-size: 10px; }
</style>

</head>
<body bgcolor="#999999">
<span class="style2"></span>
<table width="70%" height="100" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
    <td colspan="3" rowspan="2"><img src="PalletsOnRacks.jpg" alt="Header image" width="283" height="110" border="0" /></td>
    <td height="88" colspan="3" id="logo" valign="bottom" align="center" nowrap="nowrap"><span class="style7">Pallets  </span></td>
    <td width="2"></td>
  </tr>

  <tr bgcolor="#FFFFFF">
    <td height="31" colspan="3" id="tagline" valign="top" align="center"><span class="style10">"Your #1 Courier for Domestic and International Freight"</span> </td>
<td width="2"></td>
  </tr>

  <tr>
    <td colspan="7" bgcolor="#FFFFFF"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="7" bgcolor="#FFFFFF" background="mm_dashed_line.gif"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  </tr>

  <tr bgcolor="#FFFFFF">
  	<td colspan="7" id="dateformat" height="14">
<script language="JavaScript" type="text/javascript">
      document.write(Today);	</script>	</td>
  </tr>
  <tr>
    <td colspan="7" bgcolor="#FFFFFF" background="mm_dashed_line.gif"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  </tr>

  <tr>
    <td colspan="7" bgcolor="#FFFFFF"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

<tr>
    <td width="290" valign="top" bgcolor="#FFFFFF">
<table width="282" height="340" border="0" cellpadding="0" cellspacing="0" id="navigation">
        <tr>
          <td width="282" height="80"><a href="Index.html" class="navText">Home</a></td>
        </tr>
        <tr>
          <td height="80"><a href="quoteDomestic.html" class="navText">Get a Quote (Domestic) </a></td>
        </tr>
        <tr>
          <td height="80"><a href="quoteUK.html" class="navText">Get A Quote (UK) </a></td>
        </tr>
        <tr>
          <td height="80"><a href="contact.html" class="navText">Online Order </a></td>
        </tr>
        <tr>
      </table>
    <td width="10"></td>
    <td colspan="2" valign="top"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /><br />
        <table width="100%" height="400" border="0"  align ="left"cellpadding="0" cellspacing="0" background="Globe.jpg">
	"Hello, You have queried an order of

<?php echo "Hello, You have queried an order of $FullPallet full pallets and $QuarterPallet  quarter pallets. The delivery is from $DeliveryFrom and is going to $DeliveryTo. This is a ".$HTTP_GET_VARS['DeliveryType']."delivery."?>

</table>
  <tr>
    <td width="290"></td>
    <td width="10"></td>
    <td width="1"></td>
    <td width="554"></td>
    <td width="4"></td>
    <td width="3"></td>
<td width="2"></td>
  </tr>
</table>
<img src="mm_spacer.gif" alt="" width="305" height="1" border="0" />
</body>
</html>

 

Domestic.html

 

 

<html>
<head>
<title>Quote Ireland</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="mm_health_nutr.css" type="text/css" />
<script>
var d=new Date();
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
</script>
<style type="text/css">
<!--
.style2 {color: #FFFFFF}
.style3 {
color: #000000;
font-weight: bold;
}
.style7 {color: #000000; font-weight: bold; font-size: 36px; }
.style10 {color: #993300; font-weight: bold; font-size: 10px; }
.style11 {font-size: 16px}
.style12 {
color: #666666;
font-weight: bold;
}
</style>

</head>
<body bgcolor="#999999">
<span class="style2"></span>
<table width="70%" height="100" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
    <td colspan="3" rowspan="2"><img src="PalletsOnRacks.jpg" alt="Header image" width="283" height="110" border="0" /></td>
    <td height="88" colspan="3" id="logo" valign="bottom" align="center" nowrap="nowrap"><span class="style7">Pallets  </span></td>
    <td width="2"></td>
  </tr>

  <tr bgcolor="#FFFFFF">
    <td height="31" colspan="3" id="tagline" valign="top" align="center"><span class="style10">"Your #1 Courier for Domestic and International Freight"</span> </td>
<td width="2"></td>
  </tr>

  <tr>
    <td colspan="7" bgcolor="#FFFFFF"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

   <tr>
    <td colspan="7" bgcolor="#FFFFFF" background="mm_dashed_line.gif"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  </tr>

  <tr bgcolor="#FFFFFF">
  	<td colspan="7" id="dateformat" height="14">
<script language="JavaScript" type="text/javascript">
      document.write(TODAY);	</script>	</td>
  </tr>
  <tr>
    <td colspan="7" bgcolor="#FFFFFF" background="mm_dashed_line.gif"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
  </tr>

  <tr>
    <td colspan="7" bgcolor="#FFFFFF"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
  </tr>

<tr>
    <td width="290" valign="top" bgcolor="#FFFFFF">
<table width="282" height="340" border="0" cellpadding="0" cellspacing="0" id="navigation">
        <tr>
          <td width="282" height="80"><a href="Index.html" class="navText">Home</a></td>
        </tr>
        <tr>
          <td height="80"><a href="quoteDomestic.html" class="navText">Get a Quote (Domestic) </a></td>
        </tr>
        <tr>
          <td height="80"><a href="quoteUK.html" class="navText">Get A Quote (UK) </a></td>
        </tr>
        <tr>
          <td height="80"><a href="contact.html" class="navText">Online Order </a></td>
        </tr>
        <tr>
      </table>
    <td width="10"></td>
    <td colspan="2" valign="top"><img src="mm_spacer.gif" alt="" width="305" height="1" border="0" /> <img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /><br />
        <table width="100%" height="400" border="0" align="left" cellpadding="0" cellspacing="0" background="Globe.jpg">
          <tr>
            <td width="553" height="40" class="pageName style3"><h1 class="style11"><u>Get a Quote</u></h1></td>
          </tr>
          <form name="myform"  method="get" action="domestic.php">
            <tr>
              <td height="15%" class="bodyText style12">Delivery Service:</td>
              <td align="right"><select name="Delivery">
                  <option value='24 Hour' >24 Hour</option>
                  <option value='Am Delivery' >AM Delivery</option>
                  <option value='Timed Delivery'>Timed Delivery</option>
                  <option value='Saturday Delivery'>Saturday Delivery</option>
              </select></td>
            </tr>
            <tr>
              <td height="15%" class="bodyText style12" align="left">Full Pallet:<br /></td>
              <td align="right"><select name="FullPallet">
                  <option value="0" selected> 0 </option>
                  <option value="1"> 1 </option>
                  <option value="2"> 2 </option>
                  <option value="3"> 3 </option>
                  <option value="4"> 4 </option>
                  <option value="5"> 5 </option>
                  <option value="6"> 6 </option>
                  <option value="7"> 7 </option>
                  <option value="8"> 8 </option>
                  <option value="9"> 9 </option>
                  <option value="10"> 10 </option>
                </select>              </td>
            </tr>
            <tr>
              <td height="15%" class="bodyText style12" align="left">Carton:<br /></td>
              <td align="right"><select name="QuarterPallet">
                  <option value="0" selected> 0 </option>
                  <option value="1 to 3"> 1 - 3 </option>
                  <option value="4 to 6"> 4 - 6 </option>
              </select></td>
            </tr>
            <tr>
              <td height="15%" class="bodyText style12">Delivery From</td>
              <td align="right"><select name="DeliveryFrom" size="1">
                  <option value='Dublin' >Dublin</option>
                  <option value='2' >Wicklow</option>
                  <option value='3' >Wexford</option>
                  <option value='4' >Carlow</option>
                  <option value='5' >Kildare</option>
                  <option value='6' >Meath</option>
                  <option value='7' >Louth</option>
                  <option value='8' >Monaghan</option>
                  <option value='9' >Cavan</option>
                  <option value='10' >Longford</option>
                  <option value='11' >Westmeath</option>
                  <option value='12' >Offaly</option>
                  <option value='13' >Laois</option>
                  <option value='14' >Kilkenny</option>
                  <option value='15' >Waterford</option>
                  <option value='16' >Cork</option>
                  <option value='17' >Kerry</option>
                  <option value='18' >Limerick</option>
                  <option value='19' >Tipperary</option>
                  <option value='20' >Clare</option>
                  <option value='21' >Galway</option>
                  <option value='22' >Mayo</option>
                  <option value='23' >Roscommon</option>
                  <option value='24' >Sligo</option>
                  <option value='25' >Leitrim</option>
                  <option value='26' >Donegal</option>
                  <option value='27'>Armagh</option>
                  <option value='28'>Derry</option>
                  <option value='29'>Down</option>
                  <option value='30'>Fermanagh</option>
                  <option value='31'>Tyrone</option>
                  <option value='32'>Antrim</option>
                </select>              </td>
            </tr>
            <tr>
              <td  height="15%" class="bodyText style12">Delivery To</td>
              <td align="right"><select name="DeliveryTo" size="1">
                  <option value='Dublin' >Dublin</option>
                  <option value='2' >Wicklow</option>
                  <option value='3' >Wexford</option>
                  <option value='4' >Carlow</option>
                  <option value='5' >Kildare</option>
                  <option value='6' >Meath</option>
                  <option value='7' >Louth</option>
                  <option value='8' >Monaghan</option>
                  <option value='9' >Cavan</option>
                  <option value='10' >Longford</option>
                  <option value='11' >Westmeath</option>
                  <option value='12' >Offaly</option>
                  <option value='13' >Laois</option>
                  <option value='14' >Kilkenny</option>
                  <option value='15' >Waterford</option>
                  <option value='16' >Cork</option>
                  <option value='17' >Kerry</option>
                  <option value='18' >Limerick</option>
                  <option value='19' >Tipperary</option>
                  <option value='20' >Clare</option>
                  <option value='21' >Galway</option>
                  <option value='22' >Mayo</option>
                  <option value='23' >Roscommon</option>
                  <option value='24' >Sligo</option>
                  <option value='25' >Leitrim</option>
                  <option value='26' >Donegal</option>
                  <option value='27'>Armagh</option>
                  <option value='28'>Derry</option>
                  <option value='29'>Down</option>
                  <option value='30'>Fermanagh</option>
                  <option value='31'>Tyrone</option>
                  <option value='32'>Antrim</option>
                </select>              </td>
            </tr>
            <tr>
              <td align="right" colspan="2"><input name="Submit" type="submit" value="Submit"/>
                  <input type="reset" name ="reset" value="Reset" />
                  <p></p></td>
            </tr>
          </form>
        </table>
  <tr>
    <td width="290"></td>
    <td width="10"></td>
    <td width="1"></td>
    <td width="554"></td>
    <td width="4"></td>
    <td width="3"></td>
<td width="2"></td>
  </tr>
</table>
</body>
</html>

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.