Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,158,288 members, 7,836,273 topics. Date: Wednesday, 22 May 2024 at 01:39 AM

Html Submit Form.pls Help! - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Html Submit Form.pls Help! (1008 Views)

Submit Your Site To Top Instant Approval Directories Free / Pls Can U Assist Me With Login/submit Form Scripts? / How To Create An Autoresponder In An Html Form (2) (3) (4)

(1) (Reply) (Go Down)

Html Submit Form.pls Help! by gdcomms: 12:05pm On Jun 26, 2010
Hello House.I have created an html submit form, so users can send comments/feedback to a specified email address,I have tetsed it but it's not working.What am I missin?Kindly me help me out!

In anticipation
Re: Html Submit Form.pls Help! by Nobody: 2:04pm On Jun 26, 2010
lets see the code u used na, Its usually PHP or whatever language that will do the mailing of the posted stuffs from the HTML ,
Re: Html Submit Form.pls Help! by DualCore1: 2:30pm On Jun 26, 2010
Gdcomms, you will be a good developer in a couple of months. You ask questions when you're stuck.

gdcomms:

What am I missin?
Unfortunately we are not psychic so we cant know what you are missing until we see what this thread is missing i.e the codes you have written. wink
Re: Html Submit Form.pls Help! by gdcomms: 11:07pm On Jun 27, 2010
See codes:

<FORM action="mailto:you@yourdomain.com" method="post" enctype="text/plain">
<input type=hidden name="redirect" value="http://www.yoursite.com/thankyou.html">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="4" WIDTH="90%">
<TR>
<TD width="30%"><DIV align="right">
<B>Name:</B>
</DIV>
</TD>
<TD width="70%">
<INPUT type="text" name="name" size="20">
</TD>
</TR>
<TR>
<TD><DIV align="right"><B>Email:</B></DIV>
</TD>
<TD>
<INPUT type="text" name="email" size="20">
</TD>
</TR>
<TR>
<TD><DIV align="right">
<B>Comment:</B>
</DIV>
</TD>
<TD><TEXTAREA name="comment" cols="30" wrap="virtual" rows="4">
</TEXTAREA>
</TD></TR>
<TR>
<TD>&nbsp;</TD>
<TD>
<INPUT type="submit" name="submit" value="Submit">
<INPUT type="reset" name="reset" value="Reset">
</TD></TR>
</TABLE>
</FORM>

@Dual & Don, I must say I have learnt a great deal in this forum.Sometimes I have asked silly quests.Am taking all lessons by myself thats why,hope u understand.I will be launching my first website in a few days the only probe is this email form stuff.When am done hope you guys will review for me?If you got any better & simple codes out for me,kindly give me a push.
G bls u
Re: Html Submit Form.pls Help! by DualCore1: 5:42am On Jun 28, 2010
Gdcomms, your problem lies in the first line - the form's "action".

Let me do some background explanation first. Html on its own cannot submit forms so putting the email address in the form's "action" will not do any good. Html deal more with presentation logic i.e what you see on the browser. Html then has to interact with a serverside language to deal with data processing or manipulation.

In the case of this form. You have used html to present the form to the user. Now html has done its part, it now has to interact with a serverside language like PHP to process the form when the user click submit. The form interacts with the PHP processor file through the form "action". So, you have to put the link to the php file in the form's "action". You also have to build that php file to do exactly what you want i.e process the submitted content and send to your mailbox.

I am not going to make your morning a swell one by giving you the exact code to work for your form, I will do a complete working example and leave you to figure out how to make it work in your case.

I have to give the example in my next post, I dont want to put everything in one post as I do not know how the anti-spam bot thinks.
Re: Html Submit Form.pls Help! by DualCore1: 6:01am On Jun 28, 2010
Ok here's the deal. I will write a simple form and  a php file to process the form. Please note I am not taking into consideration things like security (read up on google and implement the best way you can). I don't touch security issues in my examples because it gives the bad guys an idea of how I work.


Here's the form.

<form method="post" action="myprocessor.php">
<table>
<tr>
<td><label for ="firstname">First Name</label></td>
<td><input type="text" id="firstname" name="firstname" /></td>
<tr>
<tr>
<td><label for ="lastname">Last Name</label></td>
<td><input type="text" id="lastname" name="lastname" /></td>
<tr>
<tr>
<td><label for ="email">Email</label></td>
<td><input type="text" id="email" name="email" /></td>
<tr>
<tr>
<td></td>
<td><input type="submit" id="submit" name="submit" value="Submit"/></td>
<tr>
</table>
</form>


The PHP- myprocessor.php
<?php
//i am collecting the values from the form using the global POST
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];

//we have gotten the form details over to php, now lets chunk them up into one message body
//the message variable holds what the email body will look like when u receive the mail
$message = "This are the details of the form submission\n" //the slash and "n" that you see there takes the focus to a new line
."First Name: $firstname\n"
."Last Name: $lastname\n"
."Email: $email\n";

//now lets get a subject for the email that will be sent
$subject = "Form submission";

//now declare your email as a variable, the email you want the stuff to be sent to
$mailto = "ceo.gdcomms@microsoft.com"; //amen

//add a header to get cleared by the likes of yahoo, gmail  e.t.c

$header = "From: $email\n"
. "Reply-To: $email\n";

//now lets play using the php mail function to send the data to your email

if(mail($mailto, $subject, $message, $header)){
echo "yes! we did it. form has been sent";
}
else{
else "ouch! there was an error";
}
?>


Thats all smiley

I am hoping someone will use my codes to explain further.
I'm hoping the codes are bug-free too, didnt test it but i don't see a reason why it wont work  tongue
Re: Html Submit Form.pls Help! by DualCore1: 6:06am On Jun 28, 2010
I don type the code o. Bot has blocked it. Hope someone knows how to type codes here without being chopped. If/when seun comes online, I will ask him to unblock my post. If you drop your email, I can mail it to u.


Edit: its been unblocked shocked
Now that's very fishy cuz seun is not online
Re: Html Submit Form.pls Help! by bytci(m): 6:20am On Jun 28, 2010
great post from dual, why not use a form to email service that will grab the user info from your form and email it to you. it will generate the codes for you without stressing yourself.

i use this service in this link for church www.kgrconline.com/joinaministry.html you can get the service free from this site www.mailjol.net
Re: Html Submit Form.pls Help! by DualCore1: 6:24am On Jun 28, 2010
bytci:

great post from dual, why not use a form to email service that will grab the user info from your form and email it to you. it will generate the codes for you without stressing yourself.

i use this service in this link for church www.kgrconline.com/joinaministry.html you can get the service free from this site www.mailjol.net
Thanks brotha but if we all used services like that in our early learning stages how would we learn? wink
Re: Html Submit Form.pls Help! by bytci(m): 6:32am On Jun 28, 2010
thanks dual just to encourage beginners because it is difficult to learn this code and also expensive to get good training from professionals like you guys
Re: Html Submit Form.pls Help! by gdcomms: 1:25pm On Jun 28, 2010
Dual here's my email: restoringh@yahoo.com

Waitinnnnggggg!

Thanks all!
Re: Html Submit Form.pls Help! by DualCore1: 2:05pm On Jun 28, 2010
gdcomms:

Dual here's my email: restoringh@yahoo.com

Waitinnnnggggg!

Thanks all!
No need for your email na. The post has been unblocked.
Re: Html Submit Form.pls Help! by Nobody: 4:26pm On Jun 28, 2010
Hey did not see a notification of a reply to this thread and currently on my E90 communicator, and can't risk posting wrong codes to a beginner!

When i get home, expect a code dropped, and no spam bot can stop my codes! angry
Re: Html Submit Form.pls Help! by gdcomms: 8:41pm On Jun 28, 2010
Thanks Dual.If I may ask,I wanted to add these codes in respective areas will it still work?

<tr>
<td><label for ="subject">Subject</label>/td>
<td><input type="text" id="subject"name=subject"/></td>
<tr>



<tr>
<td><label for ="message">Message</label></td>
<td>input type ="textarea" id="message" name ="message"/></td>
<tr>



$subject = $_POST['subject'];
$message = $_POST['message'];




."Subject: $subject\n"
."Message: $message\n"


@Don Waiting for your contribution as promised
Re: Html Submit Form.pls Help! by DualCore1: 9:28pm On Jun 28, 2010
Yes it will work. Please correct this part of your code.
gdcomms:

<td><input type="text" id="subject"name=subject"/></td>
Re: Html Submit Form.pls Help! by webelite(m): 2:22pm On Jun 29, 2010
Hi guy,

Guy, you need to study that html script very well and make sure you insert the values in the correct order.

firstly, you need to add your email to where 'mailto:' is written

and add your site to where you see "http://www.yoursite.com/thankyou.html"the FORM


then, save as something.cgi


Then, create a thank you page giving it the same name that appears on the script. if the one on your script is thankyou.html, name your own the same name.

Then, use your ftp to transfer the script and the thank you page to your cgi bin, don't forget to choose ASCII on your ftp when transfering
Re: Html Submit Form.pls Help! by gdcomms: 5:11pm On Jun 29, 2010
@Dual,thanks man.Thanks! Sure I haven't missed it this time.

<td><input type="text" id="subject"name="subject"/></td>




@Webelite.Do you mean if I use my first codes and save in my cgi bin,will that give me same results?
Re: Html Submit Form.pls Help! by Nobody: 8:00pm On Jun 30, 2010
@GDcomms Sorry for the delay in helping, just been too busy coding!

Consider the three codes provided here!

The first will be called index.html, or possibly contact.html it is the same HTML page Dual dropped.

Below are the codes:

<form method="post" action="myprocessor.php">
<table>
<tr>
<td><label for ="firstname">First Name</label></td>
<td><input type="text" id="firstname" name="firstname" /></td>
<tr>
<tr>
<td><label for ="lastname">Last Name</label></td>
<td><input type="text" id="lastname" name="lastname" /></td>
<tr>
<tr>
<td><label for ="email">Email</label></td>
<td><input type="text" id="email" name="email" /></td>
<tr>
<tr>
<td><label for ="email">Message</label></td>
<td><textarea id="email" name="message" /></textarea></td>
<tr>
<tr>
<td></td>
<td><input type="submit" id="submit" name="submit" value="Submit"/></td>
<tr>
</table>
</form>

Now the page myprocessor.php is what processes the action using the PHP engine. Here is the code:

<?php
$errors = '';
$myemail = 'support@gdcomms.com';//<-----Put Your email address here.
if(empty($_POST['firstname']) ||
empty($_POST['lastname']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n <h3>Field left empty</h3>Some fields were left empty, and as such, contact can't be placed";// Put what ever message here, it's user defined
}

$fname = $_POST['firstname']; //This is the name from the html form field firstname
$lname = $_POST['lastname']; //This is the name from the html form field lastname
$email_address = $_POST['email']; //This is the name from the html form field email
$message = $_POST['message']; //This is the name from the html form field messge

if (!eregi(
"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",
$email_address))
{
$errors .= "\n<br><br> <h3>Invalid Email Address</h3>The email address provided was invalid or the field was left blank, in order to contact us, you need to provide a valid email address in the address field, on the contact page";
}

if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $fname";
$email_body = "You have received a new message. ".
" Here are the details:\n Firstname: $name \n Lastname: $lname \n Email: $email_address \n Message \n $message";

$headers = "From: $myemail";
$headers .= "Reply-To: $email_address";

mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
echo('Location: contact-form-thank-you.html');
}
?>

Now after the PHP has done its work, it uses the Location:contact-form-thank-you.html stuff you see in the code to redirect to a page named contact-form-thank-you.html

There exist just HTML codes, that tells the user Thanks for submitting. This action only takes place when the mail is successfully sent to you, you may simply use echo("Thanks for submiting "wink; instead of redirecting.

Here is the code for the method implored in this system:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Thank you!</title>
<!-- define some style elements-->
<style>
h1
{
font-family : Arial, Helvetica, sans-serif;
font-size : 16px;
font-weight : bold;
}
label,a,body
{
font-family : Arial, Helvetica, sans-serif;
font-size : 12px;
}

</style>
<!-- a helper script for vaidating the form-->
</head>
</head>

<body>
<h1>Thank you!</h1>
Thank you for submitting the form. We will contact you soon! <a href="index.html">Click here to go back Home.</a>


</body>
</html>

This code also validates email using the eregi function, so if the user used a wrong email, it will not succesfully place the contact!

But the eregi function is deprecated if you use new version of php, you may research a better validation pattern.

Thanks!
Re: Html Submit Form.pls Help! by gdcomms: 9:27pm On Jul 16, 2010
Don, thanks very much for the scripts.I haven't been online for quite sometime now.Many thanks
Re: Html Submit Form.pls Help! by Nobody: 9:48pm On Jul 16, 2010
@Gdcomms, You are welcome Sir gdcomms
Re: Html Submit Form.pls Help! by ajaxphp7: 1:03pm On Jul 22, 2010
Send your email I think I have the code that will make it work for you.
It comprises of three files The html Form, The Php file that will do the processing, and a last file for the Success or error page. the last file notify users that their message has been successfully sent.
Re: Html Submit Form.pls Help! by webfactor: 1:43pm On Jul 23, 2010
U need to be taught practically.
because u must know the genuine way of modifying the code
then, how to upload it.
you will be uploading the Thank uo page along with cgi doc
Re: Html Submit Form.pls Help! by gdcomms: 3:18pm On Jul 27, 2010
Am ok now with the codes.Dual's code gave me a turn around,then Don finally did it.Since then I have been studying the submit form stuff in different categories,reading from different ebooks.Thanks guys.For a beginner I think it's not advisable to code generators.
Am impressed Keep it up guys.

(1) (Reply)

Forum Moderators Wanted / I Need Help On This Website / Graphic Design,web Design And Motion Graphics Training Coming Up 29th Of October

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 60
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.