"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.
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.
<form action=process.php method=POST>
<td><input type=text name=val1></input></td>
<td><input type=text name=val2></input></td>
<td><textarea cols="40" rows="5" name="val3"></textarea></td>
<td><input type=submit name=submit value=submit></input></td>
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 'email@example.com' to your own email id.
//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 'firstname.lastname@example.org' to your id
mail("email@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.