rendered paste body<?phpif ($_POST['submit'] == 'Submit') { if (!$_POST['email'] || $_POST['email'] == "" || strlen($_POST['email'] > 30)) { $message = '<p>There was a problem.</p>'; } else { // Open connection to database mysql_connect("localhost", "testuser", "testpass")or die("Failure to communicate with database."); mysql_select_db("testdb"); // Insert email address $as_email = addslashes($_POST['email']); $tr_email = trim($as_email); $ip = $_SERVER['REMOTE_ADDR']; $query = "INSERT INTO mailinglist (ID, Email, Source) VALUES(2, '$tr_email', '$ip')"; $result = mysql_query($query); if (mysql_affected_rows() == 1) { $message = '<p>Your information has been recorded.</p>'; $noform_var = 1; } else { error_log(mysql_error()."\n\n", 3, "/tmp/phplog.err"); $message = '<p>Something went wrong with your signup attempt.</p>'; } } // Show the form in every case except successful submission if (!$noform_var) { $thisfile = $_SERVER['PHP_SELF']; $message = <<< EOMSG<p>Enter your email address and we will send you our weekly newsletter.</p><form method="post" action="$thisfile"><input type="text" size=25 name="email"><br><br><input type="submit" name="submit" value="submit"></form> EOMSG; }}?><html><head><style type="text/css"><!--body, p {color: black; font-family: verdana; font-size: 10pt}h1 {color: black; font-family: arial; font-size: 12pt}--></style></head><body><table border=0 cellpadding=10 width=100%><tr><td bgcolor="#F0F8FF" align=center valign=top width=17%></td><td bgcolor="#FFFFFF" align=left valign=top width=83%><h1>Newsletter sign-up form</h1><?php echo $message; ?></td></tr></table></body></html>