Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: PHP help with contact form

(134 views • 6 replies)

This topic is 1 page long.

<< < > >>
Sad

RAWRoutLOWD

Reply To Post Reply & Quote

Posted at: 5/8/08 10:29 PM

RAWRoutLOWD NEUTRAL LEVEL 03

Sign-Up: 08/16/05

Posts: 184

Hey I'm designing a website for a business, and I'm having trouble with one of the pages and I was wondering if anyone could give me a hand. I'm pretty decent and design and basic coding, but I'm completely lost when it comes to PHP, so my question will probably be pretty simple.

This is the questions page: link

Basically I copied one of those contact form codes from one of those code websites, but I'm having trouble with the customization.

This is the code I used:

<?php
// Contact subject
$subject ="$subject";
// Details
$message="$detail";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";

// Enter your email address
$to ='test@ivyapphelp.com';

$send_contact=mail($to,$subject,$message ,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "Thank you, message was sent.";
}
else {
echo "ERROR";
}
?>

There are two things that I want to add. First, I want to add in the subject line of the email that it came from the question form. So I understand that there's a line for "$header="from: $name <$mail_from>";" Is there a way I can also add "IvAppHelp Question:" before the $name? Does it have something to do with 'echo' or something?

I also need to add an input box for "hometown" to the questions form. Do I set up another variable for $hometown and place it where the $detail is?

I'm sorry, i probably sound like a complete idiot, but I never gave the time to learn php. I know I really should, but I'm lazy. Thank you for anyone who helps me out.

-RAWR!


None

RIPCGeek

Reply To Post Reply & Quote

Posted at: 5/8/08 10:59 PM

RIPCGeek FAB LEVEL 03

Sign-Up: 04/19/08

Posts: 115

Wow. You really should learn PHP to do this, it's not hard at all.

<?php

// Contact subject
$subject = $_POST['subject'];

// Details
$message = $_POST['detail'];

// Mail of sender
$mail_from = $_POST['customer_mail'];

// From
$header = 'From: '.  $name . ' <' . $mail_from . '>';

// Enter your email address
$to = 'test@ivyapphelp.com';

$send_contact = mail($to,$subject,$message ,$header);

// Check, if message sent to your email
// display message "We've recived your information"

if($send_contact){
echo "Thank you, message was sent.";
}else {
echo "ERROR";
}
?>

This is assuming you're using method="POST" on the form, if not, change all the $_POST[''];s to $_GET[''];s

BBS Signature

None

RAWRoutLOWD

Reply To Post Reply & Quote

Posted at: 5/8/08 11:35 PM

RAWRoutLOWD NEUTRAL LEVEL 03

Sign-Up: 08/16/05

Posts: 184

Thanks for the response, but I don't think there's anything wrong with the script, it works perfectly. What I needed help with was adding "IvyAppHelp Question:" to the subject line and adding the "hometown" input.


None

RIPCGeek

Reply To Post Reply & Quote

Posted at: 5/8/08 11:46 PM

RIPCGeek FAB LEVEL 03

Sign-Up: 04/19/08

Posts: 115

<?php

// Contact subject
$subject = 'IvyApp Questiom' . $_POST['subject'];

// Details
$message = $_POST['detail'];
$hometown = $_POST['hometown'];

// Mail of sender
$mail_from = $_POST['customer_mail'];

// From
$header = 'From: '.  $name . ' <' . $mail_from . '>';

// Enter your email address
$to = 'test@ivyapphelp.com';

$send_contact = mail($to,$subject,$message ,$header);

// Check, if message sent to your email
// display message "We've recived your information"

if($send_contact){
echo "Thank you, message was sent.";
}else {
echo "ERROR";
}
?>
BBS Signature

None

WoogieNoogie

Reply To Post Reply & Quote

Posted at: 5/9/08 12:33 AM

WoogieNoogie LIGHT LEVEL 14

Sign-Up: 06/26/05

Posts: 3,147

A few bad coding habits aside, you didn't even explain what you did...


None

RAWRoutLOWD

Reply To Post Reply & Quote

Posted at: 5/10/08 04:00 PM

RAWRoutLOWD NEUTRAL LEVEL 03

Sign-Up: 08/16/05

Posts: 184

Thanks for the help but I just need assistance with one more thing.
I used the code you gave me and it works perfectly, but the "hometown" info doesn't get posted into the email.

This is the code I am using:

<?php
// Contact subject
$subject = 'IvyAppHelp Question: ' . $_POST['subject'];

// Details
$message = 'Question: ' . $_POST['detail'];
$hometown = 'Hometown: ' . $_POST['hometown'];

// Mail of sender
$mail_from = $_POST['customer_mail'];

// From
$header = 'From: '. $name . ' <' . $mail_from . '>';

// Enter your email address
$to = 'ray.masaki@gmail.com';

$send_contact = mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"

if($send_contact){
echo "Thank you, message was sent.";
}else {
echo "ERROR";
}
?>

I'm assuming that you have to add the $hometown variable to this line:

$send_contact = mail($to,$subject,$message,$header);

but when I tried adding $hometown after "$message", it came up as an error. Where do I place it for it to work properly? Or do I have to adjust something else for it to work?

Thanks a lot for the help.

-Ray


None

akasquid

Reply To Post Reply & Quote

Posted at: 5/10/08 04:13 PM

akasquid NEUTRAL LEVEL 02

Sign-Up: 05/07/08

Posts: 261

You need to add hometown into the "Message" field...


All times are Eastern Daylight Time (GMT -4) | Current Time: 11:56 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!