I Need Help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Unique1126
Forum Newbie
Posts: 9
Joined: Sun Sep 04, 2005 8:20 pm

I Need Help!

Post by Unique1126 »

Hey, im new to the site. I've been working on an online portfolio to show case my graphic design. Ok, so heres where my problem begins. For my 'contact' i want to have a php form i guess u can say. . . a form where a visitor of the site can insert thier NAME, EMAIL, and a MESSAGE, and click sumbit and some how (how ever it works) i recieve the message. But i cant seem to understand how to do it. . . i understand what im asking mite take a bit of time to explain but im thankful of anyone willing to help.

im jus tired of having my email as a link for a visitor to contact me, i want to have a more advanced approach to this whole new site.


Thanks again, Rudy.
Unique1126
Forum Newbie
Posts: 9
Joined: Sun Sep 04, 2005 8:20 pm

Post by Unique1126 »

i founds this. . . . http://www.scriptarchive.com/formmail.html


im not sure if thats exactly what i need, though if it is i still dont understand how its set up or coded.

:( not understanding SUCKS!
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

Thats really easy question really i made this script a while back and it works and its really easy to know how to make it as well :) and hope you like it


email.php

Code: Select all

<html>
<body bgcolor="black">
<font color="00FF00">
<center>
<form action="mail.php" method="post">
Your Name: <input type="text" name="name"><br>
E-mail: <input type="text" name = "email"><br>
Comments<br>
<textarea name="comments"></textarea><br><br>
<input type="submit" value="Submit">
</form>
</center>
mail.php

Code: Select all

<?
$name=$_POST['name'];
$email=$_POST['email'];
$comments=$_POST['comments'];
$to="youremail@yoursite.com";
$message="$name just filled in a comment or something.. They said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Applacations From Your Site",$message,"From: $email\n")) {
echo "Thank you for your comment....";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
header("Location: http://www.yoursite.com");
?>
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

You first create a form (with HTML), in the form tag set the attribute method equal to "post", put textfields for name, etc...
then have the attribute called action in the form tag set to the url of a php script, have you php script do something like this:

Code: Select all

mail ("your_email@example.com", "subject", $_POST['message']);
that would send the contents of the 'message' text field to your email, if you want to collect names etc.. do something like

Code: Select all

$name = $_POST['name'];
$msg = $_POST['msg'];

$message = "
$name says:

$msg
";
// send $message through mail() here
info about mail() can be found at http://www.php.net/mail


as always good luck!


Edit: eh, someone beat me to it.
Unique1126
Forum Newbie
Posts: 9
Joined: Sun Sep 04, 2005 8:20 pm

Post by Unique1126 »

Code: Select all

<? 
$name=$_POST['name']; 
$email=$_POST['email']; 
$comments=$_POST['comments']; 
$to="Yungwun11@aol.com"; 


$message="$name just filled in a comment or something.. They said:\n$comments\n\nTheir e-mail address was: $email"; 


^what do i put there? do i put something like "Thank you for your message, i will be responding soon?" or something?

if(mail($to,"Applacations From Your Site",$message,"From: $email\n")) { 

^whats an application from my site?


echo "Thank you for your comment...."; 
} else { 
echo "There was a problem sending the mail. Please check that you filled in the form correctly."; 
} 
header("Location: http://www.UniqueDesigns.com"); 
?>

please tell me if im fillin anything out wrong and what i need to fill out for the parts i mentioned above. so for so many questions.
Last edited by Unique1126 on Sun Sep 04, 2005 9:59 pm, edited 1 time in total.
Unique1126
Forum Newbie
Posts: 9
Joined: Sun Sep 04, 2005 8:20 pm

Post by Unique1126 »

also, where exactly do i put the mail.php code? jus as anywhere where i would bout any html code? can i put the code underneath the form code?
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

well as long as you have both of them files in the same folder or directory it will work
and everything looks right...
Unique1126
Forum Newbie
Posts: 9
Joined: Sun Sep 04, 2005 8:20 pm

Post by Unique1126 »

can u show me an example of what would be put in the areas above i mentioned that i am unsure of?
Smackie
Forum Contributor
Posts: 302
Joined: Sat Jan 29, 2005 2:33 pm

Post by Smackie »

all you gotta change is

$to="Yungwun11@aol.com";
header("Location: http://www.UniqueDesigns.com");

Thats it..
Unique1126
Forum Newbie
Posts: 9
Joined: Sun Sep 04, 2005 8:20 pm

Post by Unique1126 »

oooooo. ok, sorry.


ima gonna give it a try today. ill let u know how it goes.

:) thanks again.
Unique1126
Forum Newbie
Posts: 9
Joined: Sun Sep 04, 2005 8:20 pm

Post by Unique1126 »

hey smackie, im having problems wit the code. is there any way u can contact me via messenger (aim) so i could give u my ftp information so u can fix what im doin wrong :?


so for being such a pain :oops:


my aim is UniqueStylez00 or Yungwun11
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Note: We have a private messaging system ;)
Unique1126
Forum Newbie
Posts: 9
Joined: Sun Sep 04, 2005 8:20 pm

Post by Unique1126 »

well i need some one to help me. . . some one i can trust.

and some one who thinks they can get smackies code to work on my site.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Unique1126 wrote:

Code: Select all

<? 
$name=$_POST['name']; 
$email=$_POST['email']; 
$comments=$_POST['comments']; 
$to="Yungwun11@aol.com"; 


$message="$name just filled in a comment or something.. They said:\n$comments\n\nTheir e-mail address was: $email"; 


^what do i put there? do i put something like "Thank you for your message, i will be responding soon?" or something?

if(mail($to,"Applacations From Your Site",$message,"From: $email\n")) { 

^whats an application from my site?


echo "Thank you for your comment...."; 
} else { 
echo "There was a problem sending the mail. Please check that you filled in the form correctly."; 
} 
header("Location: http://www.UniqueDesigns.com"); 
?>

please tell me if im fillin anything out wrong and what i need to fill out for the parts i mentioned above. so for so many questions.
Okay, I see what you're doing. Basically, the mail() function has the following parameters: To, Subject, Message, Headers. So let's say I want to mail something to you, I can do this:

Code: Select all

<?php
$to="Yungwun11@aol.com";
$subject = "Hi";
$message = "How are you?";
$myemail = "vitali@vagonweb.com";

mail ($to, $subject, $message, "From: ".$myemail);
?>
In your case, all you need to do is replace the variables I gave you with the variables coming from an HTML form. Keep in mind that the name of an HTML form field (<input type = "text" name = "myemail">) would have the same name in PHP when you add $_POST (in this case, it would be $_POST['myemail']).

Good luck, let me know if you need something else.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post by $var »

here is a non-PHP form that work s off of just an HTML page... the action="" depends on your host... and you just have to fill in the spaces that you want.

Code: Select all

<form name="form1" method="post" action="http://formmail.dreamhost.com/cgi-bin/formmail.cgi">
                    <br>
                    <input type="hidden" name="recipient" value="email@domain.com">
                    <input type=hidden name="redirect" value="http://www.domain.com/contact.php">
                    <table width="97%" border="0" cellspacing="0" cellpadding="1">
                      <tr> 
                        <td colspan="2" bgcolor="#CCCCCC" class="tourCity"> <span class="hdng3"><strong>// 
                          General Questions and Queries:</strong></span></td>

                      </tr>
                      <tr> 
                        <td width="27%" class="txtblack"><strong>Name:</strong></td>
                        <td width="73%"><input name="name" type="text" class="txtblack" id="name" size="34" maxlength="50"></td>
                      </tr>
                      <tr> 
                        <td class="txtblack"><strong>Email:</strong></td>
                        <td><input name="email" type="text" class="txtblack" id="email" size="34" maxlength="50"></td>
                      </tr>

                      <tr valign="top"> 
                        <td class="txtblack"><strong>About:</strong></td>
                        <td> 
                          <select name="select" class="txtblack">
                            <option selected>General Inquiry</option>
                            <option>Web Hosting</option>
                            <option>Mutlimedia Design</option>
                            <option>Computer Support</option>

                            <option>---</option>
                            <option>Booking Information</option>
                            <option>Promotional Help</option>
                            <option>--</option>
                            <option>Partnership</option>
                          </select></td>

                      </tr>
                      <tr> 
                        <td class="txtblack"><strong>Subject:</strong></td>
                        <td><input name="email" type="text" class="txtblack" id="email" size="34" maxlength="50"></td>
                      </tr>
                      <tr> 
                        <td valign="top" class="txtblack"><strong>Message:</strong></td>
                        <td valign="top"><textarea name="textarea" cols="32" rows="16" class="txtblack"></textarea> 
                          <br> <input name="Submit" type="submit" class="formbutton2" value="Sing it!"> 
                          <input name="Submit2" type="reset" class="formbutton" value="Reset"> 
                        </td>

                      </tr>
                    </table>
                  </form>
Post Reply