Announcement
Collapse
No announcement yet.
PHP Help - Adding Text in Variable?
Collapse
X
-
This is a very basic example/concept
PHP Code:<?php
/*Check for incoming form submit.. create your own error*/
if( isset($_POST['do']) AND $_POST['do'] == 'submitform' )
{
$string = "User has requested information on:\n\n";
foreach($_POST as $post)
{
if($post != 'do')
{
$string .= $post."\n";
}
}
/*nl2br is just to fix display, not required..
your mail handler would go in here*/
echo nl2br($string);
exit();
}
else
{
/*Do something else as the form has not been set*/
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input name="productName1" type="checkbox" value="">Product Name 1<br />
<input name="productName2" type="checkbox" value="">Product Name 2<br />
<input name="productName3" type="checkbox" value="">Product Name 3<br />
<input name="productName4" type="checkbox" value="">Product Name 4<br />
<input name="productName5" type="checkbox" value="">Product Name 5<br />
<input name="" value ="Tell what I wanna know" type="submit"><br />
<input name="do" type="hidden" value="submitform">
</form>
</body>
</html>
Leave a comment:
-
PHP Help - Adding Text in Variable?
Hello Guys... I've got a form where I'm submitting information over to a PHP script. In that script, I've got the information being sent to my e-mail address as well as being posted back to the person who entered the information.
I have 10 check boxes about different products we offer and when they select the item, I want it to be displayed in the email as:
Wants more info on: Product1Name, Product2Name, etc
Wants more info on:
Product1Name
Product2Name
etc
Code:$moreinfo =""; if ($moreinfo1 == "Yes") { $moreinfo = $moreinfo + "Product 1"; }
When I have it like that, it prints out a "0" for the value instead of "Product 1, Product 2, etc".
Am I doing something wrong in that statement? I know it works for values where $moreinfo would be 1 and we would be adding numbers, but is this the only way those statements work (in a number value) or am I just entering something wrong?
SimonTags: None
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Leave a comment: