PHP Form Help

This is a discussion on "PHP Form Help" within the PHP Forum section. This forum, and the thread "PHP Form Help are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 4th, 2007, 16:11
New Member
Join Date: May 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question PHP Form Help

OK guys so here's my problem

I'm trying to add a form on my site and I got a PHP mailform code (to send me form results to my e-mail) from http://open.appideas.com/phpMailForm/

Code: Select all
<?
$MailToAddress = "YOUR@ADDRESS.GOES.HERE";
$MailSubject = "YOUR SUBJECT HERE";
    if (!$MailFromAddress) {
    $MailFromAddress = "SENDERS@ADDRESS.GOES.HERE";
    }
$Header = "";
$Footer = "";
?>
<html>
<body bgcolor="#FFFFFF">
<font face="Arial"><center>
The following information has been delivered:
</center>

<?
    if (!is_array($HTTP_POST_VARS))
    return;
reset($HTTP_POST_VARS);
    while(list($key, $val) = each($HTTP_POST_VARS)) {
    $GLOBALS[$key] = $val;
    $val=stripslashes($val);
    echo  "<b>$key</b> = $val<br>";
    $Message .= "$key = $val\n";
    }

    if ($Header) {
    $Message = $Header."\n\n".$Message;
    }

    if ($Footer) {
    $Message .= "\n\n".$Footer;
    }

mail( "$MailToAddress", "$MailSubject", "$Message", "From: $MailFromAddress");
?>
<br><br>
<b>Thank You!</b>
<br><br>
<a href="<? echo  "$HTTP_REFERER"; ?>">Return To The Mail Form</a><br><br>
<a href="/">Home Page</a><br><br>
</body>
</html>
But I have no idea how to use it!I am a newbie to PHP!Please help me to create a working mailform.Please note that the page and the actual form are 2 different htm files! Where do I place.....

Code: Select all
<FORM ACTION="mail.php" METHOD="POST">
I tried following the readme file provided but could not understand!!

Here is a basic idea http://h1.ripway.com/spoink/page.htm
and the actual form is http://h1.ripway.com/spoink/form.htm

My webservice provider DOES support PHP scripts


Please help!!
Reply With Quote

  #2 (permalink)  
Old May 4th, 2007, 16:16
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,639
Thanks: 0
Thanked 7 Times in 7 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: PHP Form Help

I know this sounds silly, Have you changed the bit that says
Quote:
SENDERS@ADDRESS.GOES.HERE
to your e-mail address?
Reply With Quote
  #3 (permalink)  
Old May 4th, 2007, 22:03
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form Help

Sorry for the delay.

First of all, in my experiance it is allways easier to write your own scriopt than try and modify and existing one... It takes just as long to make the mods as it would to have taught yourself to write your own

With that in mind im going to help you construct a simple mail form from scratch;

1) You need an htlm form to collect your information, create this file... form.php.
The form needs to know where to send the information, and for this we are going to use "post", which is just a method for sending values between different pages.

Code: Select all
<FORM action="mail.php" method="post">
What the above line of cosde is saying is.... send this information to the page mail.php and use the method of post.

2) As with regular mail, sending it is not enough... it needs to be recieved and used aswell.

When you create your form fields, you will "name" them, and it is this "name" that will be associated with the value the user enters.

Let us assume you have a field to collect the users name ... we shall conveniantly call this field "name"

Code: Select all
		  Name: <INPUT TYPE="text" NAME="Name">
The above will create a text box, that the user will enter their name into ... once the submit button is pressed... this information will be sent to the page "mail.php" in the following form

Code: Select all
$_POST['field name']
so, now we need to process this array.

create a file called "mail.php"

the first stage is to put all of your $_POST values into normall php variables as follwos:
Code: Select all
$name = $_POST['name'];
$age = $_POST['age'];

ect ect ect .... do one for every field in your form
Now, we have something we can send in an email.

This is relativly easy, and uses a php function called "mail()"

heres and example:

Code: Select all
$email =  "your email address";
$subject = "whatever you want the mails subject to be";

$message = "$name";
$message .= "other vairables or plain text or whatever";
You can i think, have as many "$message" lines as you like, just remember the "." before subsequent "=".

You can also add headers and so on to allow you to create dynamic html emails... but that is beyond what im trying to do here.

So, we now have all our variables created, and we need to send them.

Code: Select all
mail($email, $subject, $message);
The above code sends the actual email.

IMPORTANT NOTE

When your playing with the above, and trying to make it work... remember that you need to have a correctly configured email server on the machine from which the emails are to be sent.

The easiest way is to use a live host... there are plenty of free ones that have email servers set up..... you can use your local machine... but you will need to manually set up the email server... which can be a little confusing.

My advice, find a free host and test it live.


** I hope this has gone somee way to helping you understand... if you ahve any more problems, please come back and ask away

Good luck

Accura

Last edited by Accurax; May 6th, 2007 at 14:12.
Reply With Quote
  #4 (permalink)  
Old May 5th, 2007, 14:42
New Member
Join Date: May 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form Help

Hey Accurax

Thanx a lot dude
Waiting desperately for some help!!

PS.mmfraser

That was the only thing that I had already figured out(along with Your@Address.Goes.Here and Your Subject here!!
Reply With Quote
  #5 (permalink)  
Old May 5th, 2007, 20:45
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,639
Thanks: 0
Thanked 7 Times in 7 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: PHP Form Help

hehe, i thought so! i was a little bit bored!!
Reply With Quote
  #6 (permalink)  
Old May 7th, 2007, 09:28
New Member
Join Date: May 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form Help

Hey Accurax
Thanks for your *Precious* help.

I'll try to atleast learn the basics of PHP and try the tips U gave me and work on coding my own mailform script.

When U say
Code: Select all
you need to have a correctly configured email server on the machine from which the emails are to be sent
What exactly do u mean??Tht the server eg. in my case "www.ripway.com" shud have a email server??

Here is the Phpinfo() page of the server
http://h1.ripway.com/spoink/Phpinfo.php

See if the mail server is properly configured!!(I don't understand a thing of it)
Reply With Quote
  #7 (permalink)  
Old May 10th, 2007, 10:27
New Member
Join Date: May 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form Help

Hey Accurax and all other PHP guru's out there
still waitin for a reply!!
I tried Accurax's tip and set up my own formmailer

I've made my own php page and uploaded the formmailer and all tht but when I try to test it , I get a warning

"Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for XXX@XXX.COM in \\his ip address\a directory\another directory\some more directories\mail.php on line 9" where XXX@XXX.com is my email ID

What do I do??

Last edited by Accurax; May 11th, 2007 at 07:50. Reason: removed IP address and directory structure
Reply With Quote
  #8 (permalink)  
Old May 11th, 2007, 07:50
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Form Help

sounds to me like you dont have the mail server set up correctly..... what host are u using?
Reply With Quote
Reply

Tags
form, help, php

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding / Showing form fields based on previous form input John Alexander Hopper PHP Forum 1 Mar 10th, 2008 11:30
form variable within an iframe component of a form kissfreaque PHP Forum 3 Feb 29th, 2008 13:06
form variable within an iframe component of a form kissfreaque JavaScript Forum 5 Feb 29th, 2008 11:57
[SOLVED] PHP contact form redirect to same form Posie PHP Forum 14 Jan 29th, 2008 20:28
ASP form to check weather a form value is already in the database Andrew1986 Classic ASP 3 Oct 25th, 2007 08:23


All times are GMT. The time now is 21:17.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43