Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 154536

Re: can someone help me with the PHP? PLEASE HELP!

$
0
0

This should work for you: (Change the XXXXXX's to your email address).

 

 

<?php

if (isset($_POST['submit'])) {

    // check form fields are filled in

if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['zip']) || empty($_POST['budget']))  {

$error = "Please supply the required information";

}

// check to see if checkbox has been selected

elseif(!isset($_POST['projectType'])) {

    $error = "Please supply the required information";

}

else {

    // get name

$name = trim($_POST['name']);

// get email address

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

// get phone number

$phone = trim($_POST['phone']);

// get zip

$zip = trim($_POST['zip']);

// get project type

$projectType = trim($_POST['projectType']);

// get budget

$budget = trim($_POST['budget']);

//build message

$to = "XXXX@XXXXXXXXX.XX.XX";

$subject   = "Comments from website";

$headers  = "From: $email\r\n";

$headers .= "Reply-To: $email\r\n";

$message = "Name: $name\n\n";

$message .= "Email Address: $email\n\n";

$message .= "Phone No: $phone\n\n";

$message .= "Zip: $zip\n\n";

$message .= "Project Type: $projectType\n\n";

$message .= "Budget: $budget\n\n";

mail($to, $subject, $message, $headers);

$sent = "Mail was sent successfully";

}

}

?>

<!DOCTYPE HTML>

<html>

<head>

<meta charset="UTF-8">

<title>Website Form</title>

</head>

 

<body>

 

<?php

if(isset($sent)) {

    echo "<h3>$sent</h3>";

}

if(isset($error)) {

    echo "<h3>$error</h3>";

}

    ?>

<form id="maiForm" method="post" action="">

<p>

<label for="name">Name</label><br>

<input type="text" id="name" name="name">

</p>

<p>

<label for="email">Email Address</label><br>

<input type="text" id="email" name="email">

</p>

<p>

<label for="phone">Phone No</label><br>

<input type="text" id="phone" name="phone">

</p>

<p>

<label for="zip">Zip Code</label><br>

<input type="text" id="zip" name="zip">

</p>

<p>

<label>Project Type<br>

<input type="checkbox" name="projectType" class="projectType" value="None">None

</label>

<label>

<input type="checkbox" name="projectType" class="projectType" value="New Home">New Home

</label>

<label>

<input type="checkbox" name="projectType" class="projectType" value="Renovation">Renovation

</label>

</p>

<p>

Budget<br>

<select name="budget">

<option value="">Please Select</option>

<option value="None">None</option>

<option value="300k">300k</option>

<option value="500k">500k</option>

<option value="700k">700k</option>

<option value="900k">900k</option>

<option value="More">More</option>

 

</select>

</p>

<input type="submit" name="submit" id="submit" value="submit">

</form>

</body>

</html>


Viewing all articles
Browse latest Browse all 154536

Trending Articles