Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Validation for form
    primarykey
    data
    text
    <p>I need some help getting my form completed, I want certain input fields to only accept letters, some to accept numbers, etc. Could someone help me with an example so I can learn these? I want the name to only accept letters, email to accept any but REQUIRE an "@" symbol. Hopefully if I can get help with those, I can do the rest on my own.</p> <p>Thanks so much</p> <p>Here is my php form.</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;meta name="viewport" content="width=device-width" /&gt; &lt;title&gt;Daily Dorm News&lt;/title&gt; &lt;/script&gt; &lt;body&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Your Daily Dorm News Post! &lt;/h1&gt; Welcome &lt;?php if ( isset($_GET['name']) and preg_match("/^[A-Za-z0-9]+$/", $_GET['name']) ) { echo $_GET['name']; } else { echo "You entered an invalid name!\n"; } ?&gt;&lt;br&gt; Your email address is: &lt;?php if ( isset($_GET['email']) and preg_match("/.+@.+\..+/i", $_GET['email']) ) { echo $_GET['email']; } else { echo "You didn't enter a proper email address!\n"; } ?&gt;&lt;br&gt; You Posted : &lt;?php echo $_GET["message"]; ?&gt;&lt;br&gt; This event happened :&lt;?php echo $_GET["date"]; ?&gt;&lt;br&gt; &lt;?php // set the default timezone to use. Available since PHP 5.1 date_default_timezone_set('EST'); // Prints something like: Monday 8th of August 2005 03:12:46 PM echo date('l jS \of F Y h:i:s A'); ?&gt; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is my HTML</p> <pre><code> &lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;link type="text/css" rel="stylesheet" href="index.css" /&gt; &lt;meta name="viewport" content="width=device-width" /&gt; &lt;title&gt;Daily Dorm News&lt;/title&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="/resources/demos/style.css" /&gt; &lt;script&gt; $(function() { $( "#datepicker" ).datepicker(); }); &lt;/script&gt; &lt;body&gt; &lt;div id="dorm"&gt; &lt;u&gt;Daily Dorm News&lt;/u&gt; &lt;br&gt; The best place to get your latest Dorm news &lt;/div&gt; &lt;form action="posting_wall.php" method="get"&gt; &lt;div id="container"&gt; Username:&lt;input type="text" name="name" pattern="[A-Za-z0-9]{3,15}" title="Letters and numbers only, length 3 to 15" required autofocus&gt;&lt;br&gt; E-mail: &lt;input type="email" name="email"maxlength="20" required&gt;&lt;br&gt; &lt;div class='message'&gt; Post: &lt;br&gt; &lt;textarea rows="10" cols="50" name='message' id='message' pattern=".{3,}" title="3 characters minimum" maxlength="150" required&gt;&lt;/textarea&gt; &lt;/div&gt; Date this event took place: &lt;input type="text" name='date' id="datepicker" required&gt; &lt;br&gt; &lt;/div&gt; &lt;input type="submit"&gt; &lt;input type="reset" value="Reset"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload