PHP

FORM

Form Action
action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>”
action=”<?php echo $PHP_SELF ?>”
<form method=”POST” action=”<?php echo $SCRIPT_NAME ?>”>
<html><body>
<form METHOD=”POST” ACTION=”GetFormValue.php”>
Name: <input TYPE=”TEXT” NAME=”Name”/>
Memo: <textarea NAME=”Comment” ROWS=”4″ COLS=”40″ WRAP=”PHYSICAL”> </textarea>
<input TYPE=”SUBMIT”/>

</form></body>
<!– GetFormValue.php –>
<?php echo “Name=$Name”;
echo “Text=$Comment”;
?>

Form based Email

<form action=”sendemail.php” method=post name=form1>
Name: <input name=toname size=35/>
E-mail: <input name=tomail size=35/>
CC: <input name=cc size=35/>
BCC: <input name=bcc size=35/>
<select name=priority>
<option value=1>Highest</option>
<option value=2>High</option>
<option selected value=3>Normal</option>
<option value=4>Low</option>
<option value=5>Lowest</option>
</select>
Subject: <input name=subject size=35/>
Message: <textarea cols=50 name=body rows=7></textarea>
<input name=Submit type=submit value=Submit/>
</form></body></html>

<!– sendemail.php –>
<html><body>
< ?php
$message= ” ” ;
if (empty ( $toname) || empty ( $tomail) ) {
die ( “Recipient is blank! “) ;
}else{ $to = $toname . ” <” . $tomail . “>” ; }
if ( empty ( $subject) ) { $subject=” “; }
if (($priority>0) && ($priority<6)) {
$mailheader = “X-Priority: “. $priority .”\n”;
}
$mailheader.= “From: ” . “Sales Team <sales @yourdomain.com>\n”;
$mailheader.= “X-Sender: ” . “support@yourdomain.com\n”;
$mailheader.= “Return-Path: ” . “support@yourdomain.com\n”;
if (!empty($cc)) { $mailheader.= “Cc: ” . $cc .”\n”;}
if (!empty($bcc)) { $mailheader.= “Bcc: ” . $bcc .”\n”; }
if (empty($body)) { $body=” “; }
$result = mail ($to, $subject, $body, $mailheader);
echo “<b>Mail sent to “. “$to”;
echo $subject;
echo $body;
echo $mailheader;
if ($result) {
echo “<p><b>Email sent successfully!</b></p>”;
}else{ echo “<p><b>Email could not be sent. </b></p>”;}
?>

</b><b>To</b>: < ?php echo $toname . ” [“. $tomail . ” ]”;?>
<b>CC</b>: < ?php echo $cc;?>
<b>BCC</b>: < ?php echo $bcc; ?>
<b>Priority</b>: < ?php echo $priority;?>
<b>Subject </b>: < ?php echo $subject;?>
<b>Message</b>: < ?php echo $body;?>
</body></html>

Form Based Query
Form Checkbox
Form Data
Form Select
Form TextArea
Form Validation
Hidden Field
Self Call Form
TextBox

1 Comment on “PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

*