Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 10-18-2006, 07:08 AM   #1 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,683

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Creating a form...

Ok, I'm having a helluva time creating forms for my site. Basically, I just want to make a simple form for use as a joining application, for my clan website. The website software is IPB 2.1.7

I suck at PHP, and really don't know much off the top of my head.

I found a script that I'd like to use, but I can't get it to work. It is supposed to send me an email with the form results, but it doesn't send me an email.

I put this on my page:
Code:
<form method="post" action="contact.php">
Subject:

<input type="text" name="subject" size="20">

Email:
<input type="text" name="email" size="20">

Comments:
<textarea cols="20" rows="5" name="comment"></textarea>

<input type="submit" value=" Submit "> </form>
And made a file called 'contact.php' and uploaded it. Inside, is this:
Code:
<?
$subject = $_POST['subject']; // This is will be the subject of the email
$email = $_POST['email'];
$comments = $_POST['comments'];
$submit = $_POST['submit'];

if($submit)
{
// Replace name@host.com with your email address!
mail("crazed_rider@yahoo.com", "$subject", "$email", "$comments");

}
?>
Here is a preview of it on my site:
http://www.crazed.clanafterdeath.com....php?code=test (note: I just use this for testing )

I would REALLY appreciate any help, PLEASE!

Thanks in advance.
__________________

Need website help? PM me!
CrazeD is offline  
Old 10-18-2006, 09:14 AM   #2 (permalink)
 
Newb Techie

Join Date: Oct 2006

Posts: 7

Nasky

Default

Hi

In your HTML page, you call the textarea "comment". In your PHP page, you pick up a variable called "comments". Maybe because of that...
Yet, you have to check if the mail() function is allowed on your server.
Nasky is offline  
Old 10-18-2006, 04:04 PM   #3 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,683

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default

Quote:
Originally posted by Nasky
Hi

Yet, you have to check if the mail() function is allowed on your server.
How might I do that?

EDIT: My site does have webmail, if that helps...
__________________

Need website help? PM me!
CrazeD is offline  
Old 10-18-2006, 09:47 PM   #4 (permalink)
 
Newb Techie

Join Date: Sep 2005

Posts: 21

Ross

Send a message via AIM to Ross
Default

PHP Code:
<?php

mail
("crazed_rider@yahoo.com""test subject""test message");

?>
Put that in a file, upload to your site, and run it once. Quick way to check if it will email you anything

If it doesn't, then your server either doesn't support mail() or something else is going that you probably can't fix.

If it does email you, then the problem lies in your code. I noticed this:

PHP Code:
mail("crazed_rider@yahoo.com""$subject""$email""$comments"); 
The parameters for the mail() funciton are: mail( to, subject, message, headers).

It looks like you are placing your comments field as your header parameter.

This may work:


PHP Code:
mail("crazed_rider@yahoo.com""$subject""$comments"); 
I didn't want to add your $email variable in there because you would have to sanitize it to protect from header injection but that's a whole topic in itself. If you need further help, contact me (via AIM ross2376 or email).

Hope that helps.
Ross is offline  
Old 10-19-2006, 12:59 AM   #5 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,683

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default

Thank you very much. This worked:

Code:
<?php



mail("crazed_rider@yahoo.com", "test subject", "test message");



?>
I am very relieved to know that that works, but what is wrong with the code?
__________________

Need website help? PM me!
CrazeD is offline  
 
Closed Thread

Thread Tools
Display Modes

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