Form action=""
-
Hi,
I’m trying to use my own form I’ve hand-coded, with HTML and PHP.
When I submit the form (front-end), I am redirected to a page showing:Nothing Found
Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.This is my code
$form = true; if ($_POST['submit']){ $errors = checkFields($_POST); if($errors){ $error_content = ' <div class="errors"> <ul>'; foreach($errors as $error){ $error_content .= '<li>' . $error . '</li>'; } $error_content .= ' </ul> </div>'; } else{ $to = 'emailaddress'; $from = "[email protected]"; $subject = $_POST['name'].' has contacted you'; $headers = 'From: ' .$from . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $message = '<table> <tr> <td width="300px"> <table><tr><td width="100px"> </td></tr></table> </td> <td> <img src="https://www.andrewnevins.co.uk/joe-tremlin-designs/images/full-logo.png" style="display: block; float: left; margin-left: 50px;" alt="Joe Tremlin Designs" /> </td> </tr> <tr> <td width="300px"> </td> <td> <a href="www.joetremlindesigns.co.uk" style="color: #E61B72; font-weight: bold; font-size: 13px; font-family: verdana, arial, sans-serif; text-decoration: none !important;"> www.joetremlindesigns.co.uk </a> </td> </tr> </table>'. '<p style="color: #666; font-weight: lighter; font-size: 13px; font-family: verdana, arial, sans-serif;">'. '<span style="font-family: verdana, arial, sans-serif; font-weight: bold">'.$_POST['name']. '</span>' . ' has filled out your Contact form.</p>' . '<p style="font-size: 14px; color: #1D70B7; font-weight: bold;"> Details: </p>'. '<p style="font-size: 12px"><span style="font-family: verdana, arial, sans-serif; font-weight: bold">Name: </span><span style="font-family: verdana, arial, sans-serif; ">' . $_POST['name']. '</span><br />' . '<span style="font-family: verdana, arial, sans-serif; font-weight: bold">Email: </span><span style="font-family: verdana, arial, sans-serif; ">' . $_POST['email']. '</span><br />' . '<span style="font-family: verdana, arial, sans-serif; font-weight: bold">Message: </span><span style="font-family: verdana, arial, sans-serif; ">' . $_POST['message'] . '</span></p>' ; $form = false; mail($to, $subject, $message, $headers); } } if ($form){ ?> <p> Or email me using this form:<br /> <span class="bold">All fields required.</span> </p> <?php echo $error_content; ?> <div class="form clearfix"> <form action="" method="post"> <label for="name">Name</label> <div> <input required="required" type="text" value="<?php echo $_POST['name'] ?>" name="name" autofocus="autofocus"/> </div> <label for="email">Email Address</label> <div> <input required="required" type="text" value="<?php echo $_POST['email'] ?>" name="email"/> </div> <label for="message">Message</label> <div> <textarea required="required" rows="5" name="message"><?php echo $_POST['message'] ?></textarea> </div> <input type="submit" name="submit" value="send" class="submit" /> </form> </div> <?php } else{ ?> <p> <span class="green bold">Thank you</span> <span class="green"><?php echo $_POST['name'] ?></span> for taking the time to contact me.</p> <p>I will try to get back to you through your email <span class="green"><?php echo $_POST['email'] ?></span> as soon as possible. </p> <?php } ?>
Any idea why I can’t redirect to the same page?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Form action=""’ is closed to new replies.