Jump to content

A very simple web to email form


BookSense

Recommended Posts

Hi guys.

I had an online email form working until my old host decided to delete most of my files.

I have spent all day searching for an alternative to no avail.

All I am looking for is a form that can be placed in an iframe where users can send an email from the website to a specified email address.

 

Can anybody help me please?

Thanks

Link to comment
Share on other sites

Your host didn't do backups for you?  Was this a free host or a paid one?  And - where did you actually do your code-writing?  On your own pc, no?  So where are those files?

This doesn't sound like something that can actually happen.

Edited by ginerjm
Link to comment
Share on other sites

9 minutes ago, ginerjm said:

Your host didn't do backups for you?  Was this a free host or a paid one?  And - where did you actually do your code-writing?  On your own pc, no?  So where are those files?

This doesn't sound like something that can actually happen.

Unfortunately it does happen

 

Link to comment
Share on other sites

Hi @BookSense

I always come here to learn and ask others for advice. 

I'm always asked to show my code, what I've tried, explain why things don't work, what errors I get, what debugging I've done. etc.

You mentioned you've downloaded loads of email scripts but none work. Why? What errors do you get? What did you try? You didn't share anything here for others to help.

If they ALL failed, then maybe it's more server related!?

I get embarrassed asking for help at times, especially when I simply don't 'get it' but it's the only way to learn and sometimes I can sense the frustration in the people trying to point out the glaringly obvious. I'm constantly trying to learn and improve.

It does feel despite what appears to have been a truly terrible day, you may need to try harder! You mentioned you 'redeveloped all my other front-end software ' surely that's pretty skilled, so seems odd you can't sort the form!?

Below is a very simple script - it may work, it may not. 

Contact Page:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Contact Us</title>
</head>

<body>
<form method="post" name="contact" action="contact.php">
    Your Name:
    <input type="text" name="name">

    Email Address:
    <input type="text" name="email">

    Message:
    <textarea name="message"></textarea>

    <input type="submit" value="Submit">
</form>	
	
<script language="JavaScript">
var validate  = new Validator("contact");
validate.addValidation("name","req","Please provide your name");
validate.addValidation("email","req","Please provide your email");
validate.addValidation("email","email","Please enter a valid email address");
</script>	
</body>
</html>

contact.php

$errors = '';
$myemail = 'yourname@website.com';//<-----Put Your email address here.
if(empty($_POST['name'])  || 
   empty($_POST['email']) || 
   empty($_POST['message']))
{
    $errors .= "\n Error: all fields are required";
}

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address))
{
    $errors .= "\n Error: Invalid email address";
}
                                              
if( empty($errors))

{

$to = $myemail;

$email_subject = "Contact form submission: $name";

$email_body = "You have received a new message. ".

" Here are the details:\n Name: $name \n ".

"Email: $email_address\n Message \n $message";

$headers = "From: $myemail\n";

$headers .= "Reply-To: $email_address";

mail($to,$email_subject,$email_body,$headers);

//redirect to the 'thank you' page

header('Location: thank-you.htm');

}                                              

thank-you.htm:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Thank You</title>
</head>

<body>
Thanks	
</body>
</html>

Maybe try that, if it doesn't work, try debugging it to find out why.

If it's not got enough data capture fields, hopefully, it's a good starting point to develop!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.