note 116354 added to tutorial.forms

From: Date: Wed, 17 Dec 2014 10:35:04 +0000
Subject: note 116354 added to tutorial.forms
Groups: php.notes 
Request: Send a blank email to php-notes+get-201212@lists.php.net to get a copy of this message
<?php if(isset($_POST['submit'])) { $mail = $_POST['mail']; $subject = $_POST['subject']; $msg = $_POST['msg']; $headers = 'From: System <noreply@example.com>'; $name=array($mail,$subject,$msg); foreach ($name as $name) { if (ereg("^\<",$name)) { echo "<center>Invalid Characters: <a href=\"javascript:history.go(-1)\">Go Back</a></center>"; Die(); } if (ereg("^\[",$name)) { echo "<center>Invalid Characters: <a href=\"javascript:history.go(-1)\">Go Back</a></center>"; Die(); } if (ereg("^\$",$name)) { echo "<center>Invalid Characters: <a href=\"javascript:history.go(-1)\">Go Back</a></center>"; Die(); } if (strlen($name) < 3) { echo "<center>Field must be at least 3 characters long: <a href=\"javascript:history.go(-1)\">Go Back</a></center>"; Die(); } if (strlen($name) > 120) { echo "<center>Max Characters in Field: 120 <a href=\"javascript:history.go(-1)\">Go Back</a></center>"; Die(); } } mail($mail, $subject, $msg,$headers); echo "O.K."; }else{ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script language="JavaScript"> function validationEmail(maForm) { if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(maForm.mail.value)){ return (true) } alert("Invalid E-mail Address! Please re-enter.") return (false) } </script> </head> <form name="maForm" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" onSubmit="return validationEmail(this)"> <input type=text name="mail" value="e-Mail"><br> <input type=text name="subject" value="e-Mail subject"><br> <input type=text name="msg" value="e-Mail message"><br> <input type="submit" name="submit" value="submit"> </form> <?php } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 117.199.119.164 ---- Manual Page -- http://php.net/manual/en/tutorial.forms.php Edit -- https://master.php.net/note/edit/116354 Del: integrated -- https://master.php.net/note/delete/116354/integrated Del: useless -- https://master.php.net/note/delete/116354/useless Del: bad code -- https://master.php.net/note/delete/116354/bad+code Del: spam -- https://master.php.net/note/delete/116354/spam Del: non-english -- https://master.php.net/note/delete/116354/non-english Del: in docs -- https://master.php.net/note/delete/116354/in+docs Del: other reasons-- https://master.php.net/note/delete/116354 Reject -- https://master.php.net/note/reject/116354 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201212) next »