 |

03-29-2004, 07:20 PM
|
 |
Great Diviner
Great Diviner
|
|
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
|
|
Contact form
Ok, so I've been working on my site and i'm getting really close to getting it live, (except for a couple of things...) one is the contact page... here is the form
Code:
<form METHOD=POST ACTION="contact1.php">
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Name:</td>
<td><INPUT TYPE="text" NAME="name"></td>
</tr>
<tr>
<td>E-mail:</td>
<td><INPUT TYPE="text" NAME="email"></td>
</tr>
<tr>
<td valign="top">Comments:</td>
<td><TEXTAREA NAME="comments" ROWS="10" COLS="34"></TEXTAREA></td>
</tr>
<tr>
<td>
<input type="submit" name="Submit" value="Submit"></td>
<td>
<input type="reset" name="reset" value="Reset"></td>
</tr>
</table>
</form>
and here is "contact1.php" code...
Code:
<? // THIS IS THE BEGIINNING OF THE PHP CODE
$name = @$HTTP_POST_VARS['name'];
$address = @$HTTP_POST_VARS['address'];
$state = @$HTTP_POST_VARS['state'];
$city = @$HTTP_POST_VARS['city'];
$zip = @$HTTP_POST_VARS['zip'];
$country = @$HTTP_POST_VARS['country'];
$phone = @$HTTP_POST_VARS['phone'];
$email = @$HTTP_POST_VARS['email'];
$comments = @$HTTP_POST_VARS['comments'];
$fax = @$HTTP_POST_VARS['fax'];
$error_msg="";
$msg="";
$sender_email="";
if(!isset($name)){
if($name==""){
$sender_name="Web Customer";
}
}else{
$sender_name=$name;
}
if(!isset($email)){
if($email==""){
$sender_email="Customer@website.com";
}
}else{
$sender_email=$email;
}
if($error_msg != ""){
echo"You didn't fill in these required fields:
"
. nl2br($error_msg) .'
Please return to the'
." previous page and try again.";
exit;}
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $sender_name <$sender_email>\r\n";
$mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n";
mail("","",stripslashes($msg), $mailheaders);
echo "<h2>Thank you for your feedback $name</h2>";
echo 'This is the information you submitted
';
echo nl2br(stripslashes($msg));
echo '
';
//THIS IS THE END OF THE PHP CODE ?>
Now I've been working on finding a contact script that works (and is free) for about 2 hours straight... and this is the first one that seems to be the closest to actually working! It seems to be pretty simple, but I can't figure out a couple of things...
1. why does it pass even if no information has been provided?
2. HOW COME I'M NOT GETTING THE CONTACT INFO EMAILED TO ME?!!!!
Thanks!
|

03-30-2004, 06:14 PM
|
 |
Administrator
Great Diviner
|
|
Join Date: Aug 2002
Location: Maine
Posts: 5,248
Rep Power: 10
|
|
Bro, I'll try and play with this soon. Pretty fuggin busy today. Have a massiv PHP project we are rolling out over the next month (and that's just stage one), so unfortunately I have a zillion lines of my own code to pour over, lol... I will check this out though!
|

03-30-2004, 07:13 PM
|
 |
Great Diviner
Great Diviner
|
|
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
|
|
actually don't bother... it was a shit tutorial... I posted it on codewalkers... and basically got laughed at... but if you do have a simple contact form you could send me I'd much appreciate it! (trying to tie the remaining pieces of freshtokyo.com together!)
|

04-23-2004, 12:32 PM
|
 |
Great Diviner
Great Diviner
|
|
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
|
|
ok here's another one...
Code:
<form action="process.php" method="post">
Name: <input type="text" name="name" size="20" maxlength="20">
Email: <input type="text" name="email" size="30" maxlength="30">
Subject: <input type="text" name="subject" size="30" maxlength="30">
Content: <textarea name="text" cols="50" rows="10"></textarea>
<input type="submit" name="submit" value="Send">
</form>
and to process the form...
Code:
<?php
@extract ($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$text = stripslashes($text);
mail ('matt@freshtokyo.com',$subject,$text,"From: $name <$email>");
header ("location:contact.php");
?>
Any ideas why this isn't working? Should this work off my Laptop or does it need to be out there on the web to work?
|

04-23-2004, 12:47 PM
|
 |
Administrator
Great Diviner
|
|
Join Date: Aug 2002
Location: Maine
Posts: 5,248
Rep Power: 10
|
|
Have you tried echoing the variables to see if they are receiving the proper values?
Sample code is nice, but I would be less dependent on existing code to find your way, and try coming up with your own solution. Most of the problems you run into are basic syntax errors, or application control logic failures that can be addressed with some standard debugging techniques.
Making code that works, and making code that you understand, are two totally different things. Not saying you don't understand wth it's doing, but I see you wrestling with a ton of sample code when you could probably work through one on your own and really learn what the code is doing, why it's written as it is, how the application logic is controlled, etc. Guarantee you spend 10 hours fuxoring around with some little problem, when you finally figure it out, it will be both exhilerating and educational.
|

04-23-2004, 03:09 PM
|
 |
Great Diviner
Great Diviner
|
|
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
|
|
that's it... i'm going to molest this code. ;D thx for the input
|

04-23-2004, 03:09 PM
|
 |
Great Diviner
Great Diviner
|
|
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
|
|
oh man... there is no smilie for ;D how about
|

04-23-2004, 03:11 PM
|
 |
Great Diviner
Great Diviner
|
|
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
|
|
ok few
|

04-23-2004, 07:30 PM
|
 |
Administrator
Great Diviner
|
|
Join Date: Aug 2002
Location: Maine
Posts: 5,248
Rep Power: 10
|
|
Hehe good luck  Don't hesitate to post your questions obviously just giving my $.02 based on my very similar experience of learning PHP.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:05 PM.
|
|