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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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("kalcotter1@yahoo.com", "Someone Registered at BuyWithoutDebt",

$name, "From: BuyWithoutDebt");

 

 

 

?>

Link to comment
Share on other sites

When I tried it, I actually cut and pasted it from online I think... so I think I had it right... but I'll try again...  where exactly does it go... are all those dots (.) necessary?  I'm sure I have this messed up...

Link to comment
Share on other sites

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'];

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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("kalcotter1@yahoo.com", "Someone Registered at BuyWithoutDebt", $name, "From: BuyWithoutDebt");
}

?>

Link to comment
Share on other sites

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...  BuyWithoutDebt@p3slh142.shr.phx3.secureserver.net  is it possible to make that smaller... or just make it say, BuyWithoutDebt?  Just curious... Thanks again!

Link to comment
Share on other sites

Looking at your mail function:

 

mail("kalcotter1@yahoo.com", "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("kalcotter1@yahoo.com", "Someone Registered at BuyWithoutDebt", $name, "From: BuyWithoutDebt@example.com\r\nReply-To: noreply@example.com\r\n");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.