Jump to content

Simple Email Form


Charlott

Recommended Posts

Right so i'm trying to make a subscribe page at the moment for my website. I've got a section that's listed be the first one to see it here...from there i wanted to make a text box for the user to type their email address and then a button to submit and send me an email of the users email address.

 

Also, I wanted to make the submit button my own graphic and not just a button?

The HTML code is:

 

<form class="email" action="mailer.php" method="post">

<input name="email" type="text" size="70" />

<input class="send" type="submit" value="Send">

</form>

 

and the PHP:

 

 

<?php

/* Set e-mail recipient */

$myemail = "cweyer@hotmail.co.uk";

 

/* Check all form inputs using check_input function */

 

$email = check_input($_POST['email']);

 

 

/* If e-mail is not valid show error message */

if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))

{

show_error("E-mail address not valid");

}

 

 

/* Send the message using mail() function */

mail($myemail);

 

/* Redirect visitor to the thank you page */

header('Location: thanks.html');

exit();

 

/* Functions we used */

function check_input($data, $problem='')

{

$data = trim($data);

$data = stripslashes($data);

$data = htmlspecialchars($data);

if ($problem && strlen($data) == 0)

{

show_error($problem);

}

return $data;

}

 

function show_error($myError)

{

?>

<html>

<body>

 

<p>Please correct the following error:</p>

<strong><?php echo $myError; ?></strong>

<p>Hit the back button and try again</p>

 

</body>

</html>

<?php

exit();

}

?>

 

 

 

 

If anyone could help it would be so appreciated! To get more of an idea on my problem, visit www.itscharlottesweb.co.uk

Link to comment
Share on other sites

One last quick question. I'm trying to centre the form. I've got:

<form method="post" name="myemailform" action="form-to-email.php">

<p>;</p>

<p><br>

<input name="email" type="text" size="70">

</p>

<p>

 

 

<input type="image" SRC="subscribe.png"

WIDTH="85" HEIGHT="35"

BORDER="0" ALT="SUBMIT!">

</p>

 

</form>

 

 

 

and am trying to centre it. Anyone got any suggestions?

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.