Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Learning Sessions

session

  • Please log in to reply
3 replies to this topic

#1 ghost2012

ghost2012

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 31 October 2009 - 05:22 PM

Now that I've finally figured out what I need to be learning it is sessions.

(explaining the purpose of the code)

The form is real simple. The customer will only put in the amount they want.

<form action="order.php" method="post" style="height: 460px">
	order01<input name="order01" style="width: 40px" type="text" /> <br />
	order02<input name="order02" style="width: 40px" type="text" /><br />
	order03<input name="order03" style="width: 40px" type="text" /><br />
	<br />
	<input type="submit" value="Submit"onclick="return confirm('Are you sure you want to submit the form?');" />			
	<input name="reset" id="reset" type="reset" value="Reset" />
	</form>

The php will only print what is ordered and leave out any '0's it encounters.
Now what I don't know how to do is get information from this php (Confirmation Page) to the email. All I want is only the information that is printed on the confirmation page. I've tried to read up on sessions but i don't comprehend it that well. If anyone can show me an example based upon this code I can learn it. Thanks to all that have any comments or critiques.



<?php
$order01 = $_POST["order01"];
$order02 = $_POST["order02"];
$order03 = $_POST["order03"];

if ( $order01 > 0 ) {
echo " amount of $order01 <br />";
}

if ( $order02 > 0 ) {
echo " amount of $order02 <br />";
}

if ( $order03 > 0 ) {
echo " amount of $order03 <br />";
}
?>
<html>
<body>
<form method="post" action="">
<input type=button value="Back" onClick="history.go(-1)">
<input name="Submit" type="submit" value="Place Order" onClick="testResults(this.form)">
</form>
</body>
</html>

  • 0

#2 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 31 October 2009 - 05:29 PM

I'm not sure you need to use a session. If I understood correctly, you only want to send the $_POST data via email which would be $order01, 02 and 03. Is that correct?
  • 0

#3 ghost2012

ghost2012

    CC Newcomer

  • Just Joined
  • PipPip
  • 16 posts

Posted 31 October 2009 - 06:51 PM

Actually what would be sent is "ONLY" what is displayed on the confirmation page. If 4 of order1 and 3 of order 3 were the only thing selected that's what would show on the confirmation page or if only 2 of order2. Then that what is only showing on the confirmation page would be sent via email.
  • 0

#4 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 01 November 2009 - 05:30 AM

Ok, so it sounds like you just need to format a string and send an email on the confirmation page. You'll probably want to request the users email address in your submission form so that you can email them. :)

Here is the code otherwise:

<?php 
$order01 = $_POST["order01"];
$order02 = $_POST["order02"];
$order03 = $_POST["order03"];
$to = "customer@email.com";
$subject = "Order confirmation";
$body = "Thank you for your purchase. Price: ";

if ( $order01 > 0 ) {
echo " amount of $order01 <br />";
$body .= "$order01 \r\n";
}

if ( $order02 > 0 ) {
echo " amount of $order02 <br />";
$body .= "$order02 \r\n";
}

if ( $order03 > 0 ) {
echo " amount of $order03 <br />";
$body .= "$order03 \r\n";
}

$body .= "Thanks!";
mail($to, $subject, $body);


?>
<html>
<body>
<form method="post" action="">
<input type=button value="Back" onClick="history.go(-1)">
<input name="Submit" type="submit" value="Place Order" onClick="testResults(this.form)">
</form>
</body>
</html>

  • 0





Also tagged with one or more of these keywords: session

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download