Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Submitting Forms

Featured Replies

Guys, let's say I have this form and when someone fills it out and they press 'submit', it gets sent to a certain e-mail address...What would be the code for the 'submit' button? :) And what code would I have to put so if someone doesn't fill out a text box, when they press 'submit', it tells them that they forgot to fill something out?


I guess you mean in PHP. Here's my old contact form. You'll have to modify it to your liking.

Note: I didn't make this, so I won't be able to help with this..

<?php
$target = "your@email.address";
if (($message) && ($from) && ($subject) && ($target) && ($fromname)) {
$message = stripslashes($message);
mail(" $target ", " $subject ", $message,
    "From: $fromname <$from>\r\n"
   ."Reply-To: $from\r\n"
   ."X-Mailer: PHP/" . phpversion());
echo "<br><br>Mail sent successfully, click <a href=\"$PHP_SELF\">here</a> to send another";
}
else {
echo "
<form name=\"mail\" method=\"post\" action=\"$PHP_SELF\">
<table border=0>
<tr>
<td>Name:</td>
<td><input class=\"editbox\" type=\"text\" name=\"fromname\"><br></td>
</tr>
<tr>
<tr>
<td>E-Mail:</td>
<td><input class=\"editbox\" type=\"text\" name=\"from\"><br></td>
</tr>
<tr>
<td>Subject:</td>
<td><input class=\"editbox\" type=\"text\" name=\"subject\"><br></td>
</tr>
<tr>
<td>Message:</td>
<td><br></td>
</tr>
<tr>
<td colspan=2>
<textarea class=\"editbox\" name=\"message\" cols=\"80\" rows=\"10\"></textarea>
</td>
</tr>
<tr>
<td></td>
<td><div align=\"right\"><input class=\"button\" type=\"submit\" name=\"Submit\" value=\"Send\"></div></td>
</table>
</form>
";
}
?>

As far as the "missing data" error, you'd use something like...

if ((empty($blah1)) || (empty($blah2)) || (empty($blah3))) {
               $error = "yes";
       }
if ($error == "yes") { echo "You forgot something, dumbass"; }

Another method using formmail. (usually provided by most hosts)

Use the below template:

01. Create a table

Create a form using the below code

<form method = "post" action =

"http://www.ugrad.cs.jhu.edu/cgi-bin/cgiwrap/internet/FormMail.pl">

<input type = "hidden" name = "recipient" value = "blank@jhu.edu">

NOTE: usually your host has formmail installed, just go about doing a search, i know netfirms has it. (obviously the form mail i gave above is from my school, and that's my email)

02. Create all the form types you want

radio buttons, text fields, etc..

03. add the send/clear buttons using the following code

<input type = "submit" value = "Send"><br><input type = "reset" value = "Clear Form">

04. close the form

05. close the table

  • Author

sedative, for yours, do I have to have anything installed other than PHP and a webserver?

Mine. Its very simple.

bugs.php (rename to your likings)

<BR><form method=post action="thanks.php"><table width="300" border="0" cellspacing="0" cellpadding="0"><font face="Verdana" size="1" color="Gray">
<tr>
<td width="108"><font face="Verdana" size="1" color="Gray">cUsername:</td>
<td width="192">
<input type="text" name="name">
</td>
</tr>
<tr>
<td width="108"><font face="Verdana" size="1" color="Gray">E-Mail Address:</td>
<td width="192">
<input type="text" name="thereemail">
</td>
</tr>
<tr>
<td width="108" valign="top"><font face="Verdana" size="1" color="Gray">Title:</td>
<td width="192">
<textarea name="message"></textarea>
</td>
</tr>
<tr>
<td width="108"> </td>
<td width="192">
<input type="submit" name="Submit" value="Send Form">
</td>
</tr>
</table>
</form>

thanks.php

<?php  
if($sentemail == "2"){  
include("sorry.php");  

}else{  

$num = $sentmessage + 1;  
setcookie("sentemail","$num",time()+600); //set the cookie

$email = "Reported by:\t$name (\t$thereemail )\nMessage:\t$message\nIP Address:\t$REMOTE_ADDR\n\n";
$to = "gamehead@hisemail.com";
$subject = "Subject of submission u want";
$mailheaders = "From: $thereemail <> \n";
$mailheaders .= "Reply-To: $thereemail\n\n";
mail($to, $subject, $email, $mailheaders);
include("thanksecho.php");
}
?>

thanksecho.php

<form method=post action="thanks.php"><table width="300" border="0" cellspacing="0" cellpadding="0"><Center><center>Thank you for submitting the form.

sorry.php

(Copy code from thanksecho.php here)

  • Author

Can someone find the problem w/ this code?

<?php  

if($sentemail == "2"){  

include("sorry.php");  

}else{  

$num = $sentmessage + 1;  

setcookie("sentemail","$num",time()+600); //set the cookie

$email = "Name of Applicant:\t$name (\t$thereemail )\nDaytime Phone Number:\t$number1\nNighttime Phone Number:\t$number2\nResume:\t$resume\nIP Address:\t$REMOTE_ADDR\n\n-----------------------------------------------------------------------------------------------------

This email was sent via the Altapex job application form.";

$to = "email@email.com";

$subject = "Altapex Job Application";

$mailheaders = "From: $thereemail <> \n";

$mailheaders .= "Reply-To: $thereemail\n\n";

mail($to, $subject, $email, $mailheaders);

include("thanksecho.php");

}

?>

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.