Dreamweaver/Website form.

Advertisement


Question
"Hello, I am going to re do my website and have made a web form for it but I dont know how to enable the web form so it works. The fields I have got are Name, Email Address and Message with a submit button. I want to be able to have the form working so that it sends the message to my website email address etc. Up until now i have been fine making a basic website but this is new to me so your help would be appreciated.

Regards

Robert"

Answer
Hello,
    Good day Mr.Robert !

For creating a contact us form, you need to create a html (frontend) and a php (backend) file.

Create a html file with any name and copy the below mentioned coding in it.

<html>
<head>
<title>Contact Us</title>
</head>
<body>
<form action=process.php method=POST>
<table>
<tr>
<th>Name:</th>
<td><input type=text name=val1></input></td>
</tr>
<tr>
<th>Email:</th>
<td><input type=text name=val2></input></td>
</tr>
<tr>
<th>Address:</th>
<td><textarea cols="40" rows="5" name="val3"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type=submit name=submit value=submit></input></td>
</table>
</form>
</body>
</html>

Create a php file with the name mentioned in the front end's coding part (here, it is process.php) and copy the below mentioned coding in it. If you want to have your own backend name, you can do so, but don't forget to change the same in front end's HTML coding. Also change the mail id 'you@example.com' to your own email id.

<?php
$name=$_REQUEST['val1'];
$email=$_REQUEST['val2'];
$address=$_REQUEST['val3'];


//Concantenate all values as a string and store it in a variable named consolidatedtext.

$consolidatedtext="\n Username is"." ".$name.",  "."\n Email is"." ".$email.",  "."\n Address is \n"." ".$address;


//Use PHP mail function to send all the received details to the appropriate mail id.
//Change the mail id 'you@example.com' to your id

mail("you@example.com","New Contactus Submission",$consolidatedtext);
?>

Now, upload the two files to the webserver (if you have one). But, please do remember that both the files should reside in the same directory.

Please revert to me, for any clarifications.

I am more than happy to assist you.

Cheers !

Dreamweaver

All Answers


Answers by Expert:


Ask Experts

Volunteer


Vimal Abraham

Expertise

I have worked with HTML, PHP and MySQL from 2005. I can be able to solve HTML, PHP, and MySQL related issues.

Experience

I have worked under various domains of web development including file sharing, social community, wallpaper management, image hosting, web hosting automation, shopping cart and payment gateway integration. My portfolios include, http://www.4kwallpapers.in http://www.wallpicz.com

Education/Credentials
I have completed Bachelor of Engineering in Computer Science.

Awards and Honors
Have a Total of nine certificates in Inter and Intra College Competitions that includes technical quiz, program debugging and paper presentation (State Level).

©2016 About.com. All rights reserved.