Jump to content

contact php file for web


jiminfo

Recommended Posts

Hi Peeps, I have tried but am trying to get a website up and working and am stumbling with the php side of things. Please help.

 

html

 

<form id="contacts-form" name="contacts-form" action="contact1.php" method="post" >
                            <fieldset>
                              <div class="field">
                                <label>Your Name:</label>
                                <input type="text" class="input" name="name" id="name">
                               </div>
                              <div class="field">
                                <label>Your E-mail:</label>
                                <input type="text" class="input" name="email" id="email">
                               </div>
                              <div class="field">
                                <label>Your Website:</label>
                                <input type="text" class="input" name="website" id="website">
                               </div>
                              <div class="field">
                                <label>Your Message:</label>
                                <textarea name="textarea" id="textarea" cols="" rows=""></textarea>
                               </div>
                              <div class="alignright"><a href="contact-us.html" onclick="document.getElementById('contacts-form').submit()"><strong>Send Your Message!</strong></a></div>
                           </fieldset>
                         </form>

 

php is..

<?php
   $name    = $_POST ['name'];
   $website = $_POST ['website'];
   $email   = $_POST ['email'];
   $message = $_POST ['textarea'];
   if(!$name || !$website || !$email || !$textarea)
<form method='post' action='contact1.php'>
   Name: <br /><input name='name' type='text' value='$name' /><br /><br />
   Company: <br /><input name='website' type='text' value='$website' /><br /><br />
   EMail: <br /><input name='email' type='text' value='$email' /><br /><br />
   Message:<br />
   <textarea name='textarea' cols='55' rows='8'>$textarea</textarea><br /><br />
   <input type='submit' value='Send' />
</form>
<p>All fields are required</p>
$send_to = "info@cropredyvillage.info"; // change to your email
mail($send_to, "Name: $name: $website" , $textarea, "From: $email");
echo "Thank you for your feedback";
?>

 

form just resets and does not send a mail. I really hope you can help.

 

J

Link to comment
Share on other sites

Do you use a php editor ? You should see at once that you miss a php close tag. or is it because bad copy and paste work to this board?

 

start all over like this:

<?php

$firstname = '';
$error = NULL;

if($_SERVER['REQUEST_METHOD'] == 'POST')
{
    $firstname = $_POST['firstname'];

    //validation
    if(strlen($firstname) < 2)
        $error = 'Please fill in your firstname!';

    if(!$error)
    {
        // do some actions like sending an email
		
		// redirect
        header('Location thankyou.html');
    }
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>My first Form</title>
</head>

<body>
<p><?php echo $error; ?></p>
<form action="" method="post">
	<input type="text" name="firstname" value="<?php echo $firstname; ?>" />
    <button type="submit">Send</button>
</form>
</body>
</html>

Edited by Frank_b
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.