Forum Moderators: coopster
I'm an html guy and I'm trying to add onto someone else's php coding – and I can’t figure it out.
Basically, I want to add multiple fields to the form, but how do I code that on the php script side? I tried to just copy and paste the code, and rename some of the variables, but that doesn’t work.
Here is the script: if($_REQUEST['btnSubmit']=='Submit') $Message .="</table>"; $From=$Email; if(@mail($To,$Sub,$Message,$headers)) } Thank you so much for any help [1][edited by: jatar_k at 12:49 pm (utc) on Mar. 3, 2007]
----------------------------------------------------------
<?php
$Que=array();
$Que[0]="Do you know the demand curve and price elasticity of your main products?";
$Que="Do you often create bundles and special editions of your products for particular market segments?";
$Que[2]="Have you identified distinct market segments, and do you serve these market segments, products, and services at different price points?";
$Que[3]="Do you know what attributes of your products and services drive buying decisions and control their willingness to pay?";
{
$Ans=array();
$Email=$_REQUEST['txtEmail'];
$Message .="<table width=100% cellpadding=3 style=' font-family:verdana; font-size:10px;' >
<tr ><td colspan=2><b><Font face=verdana size=3>Price Quiz</span></b><br><br></td></tr>
<tr ><td colspan=2> Sender's Email Address: <b>$Email </b><br><br></td></tr>";
for($i=0,$c=1;$i<count($Que);$i++,$c++)
{
$Nm="rdb".$i;
if($_REQUEST[$Nm]==0) { $Ans[$i]="Yes"; }else{ $Ans[$i]="No"; }
$Message .="<tr><td width=10></td><td ><b>$c. </b> ".$Que[$i]."<br><b>A:</b> ".$Ans[$i]."</td></tr><tr><td> </td></tr>";
}
//--------------address of receiver---------------
$To="email@example.com";
$headers.="MIME-Version:1.0"."\r\n";
$headers.="content-type:text/html; charset=iso-8859-1"."\r\n";
$headers.="TO:$To"."\r\n";$headers.="From:$Email"."\r\n";
$Sub="Price Quiz ";
{
$Msg="Mail has been sent successfully";
$_REQUEST['txtEmail']="";
}
else $Msg="Sorry, the email could not be sent!";
?>
[edit reason] removed html as not needed [/edit]
Basically all your new vars will be accessible inside the $_POST superglobal assuming you have a post query. You can assign them to new vars or just work with the array vars. ie:
<input type="text" name="name">
$name = $_POST['name'];
echo $name;
or simply:
echo $_POST['name'];
You say it doesn`t work. Thats not really helping us too much. Can you give us some indications of the errors you are seeing?
dc