Jump to content

[SOLVED] simple 4 U.. I'm new... going to scream!!!!!


kcotter

Recommended Posts

I'm trying to make a simple email form...  7 fields... name, email, etc...  I want it to send an email to me.. Which it does...  but I want that email to be readable.. and normal..  as in, 7 lines...

 

Name:  my name

Email: my email

Address:  123 nowhere

etc....

 

Apparently this is impossible for me to figure out.. I know these files are messed up... I joined this forum so I can learn more about PHP. this is my first question... don't have time to read a book tonight.. please help!!!!!!!!!!!!!  thanks!  Oh.. and my next problem (that I gave up on hours ago) is making at least the name, and email fields required...  couldn't get that to work either... 

 

the simple files I'm working with are attached...  thanks for any help!!!!

 

thanks,

kal

 

[attachment deleted by admin]

Welcome to PHP Freaks!

 

Rather than attaching the files, which no one will bother downloading and then viewing, just post them via


tags.

 

To add new line breaks in email, I believe you can use "\n". Have you tried that? Of course I haven't viewed your scripts. And to make the fields required, just check for them and if they are empty, then display an error message.

I've tried the "/n" , and checking if they were empty.. I just can't figure it out, I've download multiple codes and tried them..  Here's the code in question:

 

form.php

__________________________

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

 

<html>

<head>

<title>Untitled</title>

</head>

 

<body>

<form method="Post" action="send.php">

<table border="0" cellpadding="0" cellspacing="5" width="377">

<tr>

<td width="74">Name*</td>

<td width="299"><input type="text" name="name" size="20"></td>

</tr>

<tr>

<td width="74">Email*</td>

<td width="299"><input type="text" name="email" size="20"></td>

</tr>

<tr>

<td width="74">Address</td>

<td width="299"><input type="text" name="address" size="40"></td>

</tr>

<tr>

<td width="74">City</td>

<td width="299"><input type="text" name="city" cols="20"></td>

</tr>

<tr>

<td width="74">State</td>

<td width="299"><input type="text" name="state" cols="20"></td>

</tr>

<tr>

<td width="74">Zip Code</td>

<td width="299"><input type="text" name="zip" cols="10"></td>

</tr>

<tr>

<td width="74">How did you hear about us?</td>

<td width="299"><input type="text" name="hear" cols="10"></td>

</tr>

<tr>

<td width="74"></td>

<td width="299"><input type=submit value="Submit"></td>

</tr>

</table>

</form>

 

 

</body>

</html>

 

_______________________

send.php

--------------------------

 

<?

 

 

 

PRINT "Thank you $name for registering to win!";

 

 

$name = "Name: ".$_REQUEST['name'].

$name = "Email: ".$_REQUEST['email'].

$name = "Address: ".$_REQUEST['address'].

$name = "City: ".$_REQUEST['city'].

$name = "State: ".$_REQUEST['state'].

$name = "zip: ".$_REQUEST['zip'].

$name = "How they heard about us: ".$_REQUEST['hear'];

 

 

mail("[email protected]", "Someone Registered at BuyWithoutDebt",

$name, "From: BuyWithoutDebt");

 

 

 

?>

Try this:

 

$name = "Name: ".$_REQUEST['name']."\n"
    ."Email: ".$_REQUEST['email']."\n"
    ."Address: ".$_REQUEST['address']."\n"
    ."City: ".$_REQUEST['city']."\n"
    ."State: ".$_REQUEST['state']."\n"
    ."Zip: ".$_REQUEST['zip']."\n"
    ."How they heard about us: ".$_REQUEST['hear'];

Holy cow!!! you made that too easy!!!  Thank you soooo much for your help!!!  any chance making the first two (name, email) required is that easy???  Email doesn't have to validate... just check if it's empty...  I had an if statement I was playing with, but it kept stopping at the first print (or echo) no matter what the text box had in it....  Thanks for your help.. this forum rocks!

Add something like:

 

if (empty($_REQUEST['name']) || empty($_REQUEST['email']))
{
    die('Enter name and email...');
}

 

Before creating the $name var.

 

.... or better yet:

 

<?php

print "Thank you $name for registering to win!";

if (empty($_REQUEST['name']) || empty($_REQUEST['email']))
{
    print 'Enter name and email...';
}
else
{
    $name = "Name: ".$_REQUEST['name']."\n"
    ."Email: ".$_REQUEST['email']."\n"
    ."Address: ".$_REQUEST['address']."\n"
    ."City: ".$_REQUEST['city']."\n"
    ."State: ".$_REQUEST['state']."\n"
    ."Zip: ".$_REQUEST['zip']."\n"
    ."How they heard about us: ".$_REQUEST['hear'];

    mail("[email protected]", "Someone Registered at BuyWithoutDebt", $name, "From: BuyWithoutDebt");
}

?>

This is perfect.  Thanks a lot for your help, I really appreciate it!!!  One more questions... this might be harder I'm not sure..  in my email, when I get the email that says someone signed up, and here's their info...  the "from" email is this...  [email protected]  is it possible to make that smaller... or just make it say, BuyWithoutDebt?  Just curious... Thanks again!

Looking at your mail function:

 

mail("[email protected]", "Someone Registered at BuyWithoutDebt", $name, "From: BuyWithoutDebt");

 

It's probably safer in that respect to use an email for the "From:" header, and also add a reply-to email address (even if it's noreply@...) - this may stop the long ugly email address showing. Something like:

 

mail("[email protected]", "Someone Registered at BuyWithoutDebt", $name, "From: [email protected]\r\nReply-To: [email protected]\r\n");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.