Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2005-07-12, 10:56 PM   #1
ponyman
Nobody gets into heaven without a glowstick
 
ponyman's Avatar
 
Join Date: Jun 2004
Location: The Great Northwest
Posts: 422
Send a message via ICQ to ponyman
Help with PHP submit form

I'd like to create a submit from for my LL using PHP.

Can anyone direct me to a tutorial on this?
__________________
Dirty Old Men Sponsors - gay & straight
ponyman is offline   Reply With Quote
Old 2005-07-12, 11:51 PM   #2
Halfdeck
You can now put whatever you want in this space :)
 
Halfdeck's Avatar
 
Join Date: Oct 2004
Location: New Haven, CT
Posts: 985
Send a message via ICQ to Halfdeck
For forms, I usually create an HTML page with <form action=file.php method=post(or get)>

Then write in file.php:

<?php

$useremail = $_GET['email'];
$title = $_GET['title'];
$description = ....

?>

Then either build an email message to myself or enter the info into a MYSQL DB (or both).

Let me know if you were looking for more detailed info
__________________
Success is going from failure to failure without a loss of enthusiasm.
Halfdeck is offline   Reply With Quote
Old 2005-07-13, 12:32 AM   #3
ponyman
Nobody gets into heaven without a glowstick
 
ponyman's Avatar
 
Join Date: Jun 2004
Location: The Great Northwest
Posts: 422
Send a message via ICQ to ponyman
I think that's what I need, but I'm way behind on this PHP stuff, so that still looks really confusing to me. I'm going to go do some research on this and I'll be back tomorrow, hopefully further along

I really appreciate the help!
__________________
Dirty Old Men Sponsors - gay & straight
ponyman is offline   Reply With Quote
Old 2005-07-13, 02:06 AM   #4
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
I usually prefer to use $_REQUEST['fieldname'] -- that way you don't have to worry about whether it is method="GET" or method="POST" in your form. And I prefer to use POST rather than GET anyhow.

then, you can insert the records into your database, or create an email that is mailed to you.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2005-07-13, 10:28 AM   #5
Halfdeck
You can now put whatever you want in this space :)
 
Halfdeck's Avatar
 
Join Date: Oct 2004
Location: New Haven, CT
Posts: 985
Send a message via ICQ to Halfdeck
Quote:
Originally Posted by cd34
I usually prefer to use $_REQUEST['fieldname']
Cool, I never tried that, sounds like using $_REQUEST will make life a lot easier. |cool|

Ponyman, here's an example code you can test. If you want more info, just look it up at PHP.net (I'm sure you already know that url though).

form.html:

HTML Code:
<form method="post" action="eatthis.php">
 Your Nick: 
<input name="name" type="text"><BR>
Email Addres:
<input name="email" type="text"><BR>
Subject:
<input name="subject" type="text">
Message:<textarea name="message" cols="50" rows="17">
<input name="Submit" type="submit" value="Send it baby!">
</form>
eatthis.php

PHP Code:
<?php

// Capture info sent from the form in variables

$name $_REQUEST['name'];
$email $_REQUEST['email'];
$subject $_REQUEST['subject'];
$message $_REQUEST['message'];

// Print out one of the vars on the page just to make sure you got it

echo "Who the hell sent me this MESSAGE?? $message<BR>";

// Email it to myself

mail('admin@YOUREMAILADDY.com'$subject$message"From: $name ($email)\r\n");

// Enter it in a database... Here you need to have a MYSQL table set up, lets call it EMAIL, with fields email,subject, message

// hook up to MYSQL

$link mysql_connect('localhost''YOURUSERNAME''PASSWORD') or die('Failed to connect to SQL server.\n');
mysql_select_db('TABLENAME') or die('Failed to connect to the database.\n');

//enter info into DB. Note: there may be cleaner ways of entering strings into DB, but this works for me.  Also note that how you order the values depends on how you built your MYSQL table, so you'll prolly need to play around a bit before you get it to work.

$query "INSERT INTO email (name,email,subject,message) VALUES \"$name\",\"$email\",\"$subject\",\"$message\")";

// that's the query string.  Just send it to MYSQL and you're done: 

mysql_query($query);

// If you want error reporting, use: mysql_query($query) or mysql_error();
// You can also write your own function for error reporting.  If you want to make sure you disconnect from MYSQL after you're done, use: mysql_close($link);

?>
__________________
Success is going from failure to failure without a loss of enthusiasm.
Halfdeck is offline   Reply With Quote
Old 2005-07-26, 04:37 PM   #6
ponyman
Nobody gets into heaven without a glowstick
 
ponyman's Avatar
 
Join Date: Jun 2004
Location: The Great Northwest
Posts: 422
Send a message via ICQ to ponyman
Yo halfdeck, I tried that out and I couldn't get it to work. I click on the submit button and it looks like it's working, but I get no e-mail at all.

I found this php form for e-mail, but it looks even more complicated: http://www.alt-php-faq.org/local/48/#id48
__________________
Dirty Old Men Sponsors - gay & straight
ponyman is offline   Reply With Quote
Old 2005-07-26, 04:39 PM   #7
ponyman
Nobody gets into heaven without a glowstick
 
ponyman's Avatar
 
Join Date: Jun 2004
Location: The Great Northwest
Posts: 422
Send a message via ICQ to ponyman
hmmm. the form works if I don't fill it out and just click submit, I geta a blank e-mail

here is the .php file

<?php

// Capture info sent from the form in variables


$Title = $_REQUEST['Title:'];
$URL = $_REQUEST['URL:'];
$Category = $_REQUEST['Category'];
$Type = $_REQUEST['Type'];
$Comments = $_REQUEST['Comments'];
$nickname = $_REQUEST['nickname'];
$email = $_REQUEST['email'];


// Print out one of the vars on the page just to make sure you got it

echo "Thanks for submitting to The Sexwitch! You will receive an e-mail about your site once it has been reviewed. $message<BR>";

// Email it to myself

mail('sexwitch@sexwitch.com', $Title, $URL, $Category, "From: $nickname ($email)\r\n");
?>
ponyman is offline   Reply With Quote
Old 2005-07-26, 09:08 PM   #8
pornoTGB
Shut up brain, or I'll stab you with a Q-tip!
 
pornoTGB's Avatar
 
Join Date: Jun 2005
Location: Austria
Posts: 118
Send a message via ICQ to pornoTGB
$address = ''; //the address it will be sent to
$subject = ''; //the subject that will show up
$email = ''; //the email-text
$header = ''; //email-header

mail($address,$subject,$email,$header); //this line sends the mail


you used a wrong syntax in the mail-function
mail('sexwitch@sexwitch.com', $Title, $URL, $Category, "From: $nickname ($email)\r\n");
you can't just add your variables and seperate them with a ',' The function needs the correct syntax.. find more here: http://www.php.net/manual/en/function.mail.php
another mistake is "From: $nickname ($email)\r\n" .. this would put out exactly what you have .. rather try this: 'From: '.$nickname.'<br>Message: '.$email
what this does: it takes the text 'From: ' and adds the content of the variable $nick to it. then another text and the content of $email.. remember to add dots inbetween them

Last edited by pornoTGB; 2005-07-26 at 09:09 PM.. Reason: wrong url
pornoTGB is offline   Reply With Quote
Old 2005-07-26, 11:00 PM   #9
ponyman
Nobody gets into heaven without a glowstick
 
ponyman's Avatar
 
Join Date: Jun 2004
Location: The Great Northwest
Posts: 422
Send a message via ICQ to ponyman
This is what I've got so far

<?php

// Capture info sent from the form in variables


$Title = $_REQUEST['Title:'];
$URL = $_REQUEST['URL:'];
$Category = $_REQUEST['Category'];
$Type = $_REQUEST['Type'];
$Comments = $_REQUEST['Comments'];
$nickname = $_REQUEST['nickname'];
$email = $_REQUEST['email'];


// Print out one of the vars on the page just to make sure you got it

echo "Thanks for submitting to The Sexwitch! You will receive an e-mail about your site once it has been reviewed. $message<BR>";

// The message
$message = "Line 1\nLine 2\nLine 3";

// Email it to myself
$message = "$Title\n$URL\n$Category";
$address = ' sexwitch@sexwitch.com';
$subject = 'Sexwitch Submit';
$email = ' blank';
$header = ' sexwitch@sexwitch.com';


mail($address,$subject,$email,$header,$message);
?>


It sends an e-mail with headers with the word "blank" in the body.

Now I can't figure how to add the captured text from the form into the email.
__________________
Dirty Old Men Sponsors - gay & straight
ponyman is offline   Reply With Quote
Old 2005-07-26, 11:11 PM   #10
Halfdeck
You can now put whatever you want in this space :)
 
Halfdeck's Avatar
 
Join Date: Oct 2004
Location: New Haven, CT
Posts: 985
Send a message via ICQ to Halfdeck
Like PornoTGB pointed out, you have to stick to this basic syntax:

mail($targetemail, $subject, $message);

Example: mail("paulazahn@cnn.com","Re:Nice interview last night", "Hey Paula, just saw your interview with the girl working for New York Confidential....");

If you want to add header info, then like on the example on http://us2.php.net/manual/en/function.mail.php,
use: mail($targetemail, $subject, $message, $header).

In other words, mail($subject, $target_email, $header...) or any other variants like mail($header, $subject, $to_email) ... will not work.
__________________
Success is going from failure to failure without a loss of enthusiasm.
Halfdeck is offline   Reply With Quote
Old 2005-07-27, 12:18 AM   #11
ponyman
Nobody gets into heaven without a glowstick
 
ponyman's Avatar
 
Join Date: Jun 2004
Location: The Great Northwest
Posts: 422
Send a message via ICQ to ponyman
Ok, I think I finally got my SUBMIT FORM working. If anyone wants to submit some no recip required sites to help me further test the form, please go ahead, I'll list them.
http://www.sexwitch.com/webmasters.html
__________________
Dirty Old Men Sponsors - gay & straight
ponyman is offline   Reply With Quote
Old 2005-07-27, 06:42 AM   #12
Doug E
Kids are great, Appu. You can teach them to hate the things you hate and they practically raise themselves now-a-days, you know, with the internet and all
 
Doug E's Avatar
 
Join Date: Mar 2005
Location: Canadeh
Posts: 197
i submitted and got this reply.

Quote:
SUCCESS! Thanks for submitting to The Sexwitch!
You will receive an e-mail about your site once it has been reviewed.

testest http://www.pornobobslinks.com/galler...chanapa03.html ETHNIC (Asians, Latina...) FREE just helping you test your form man, feel free to delete this gal. Doug E @ UncleWangs xxxxxxxxx@hotmail.com
__________________
Asian Porn | Sora Aoi | Natt Kesarin
Doug E is offline   Reply With Quote
Old 2005-07-27, 06:13 PM   #13
ponyman
Nobody gets into heaven without a glowstick
 
ponyman's Avatar
 
Join Date: Jun 2004
Location: The Great Northwest
Posts: 422
Send a message via ICQ to ponyman
Thanks Doug E, People's submits seem to be working fine now.
__________________
Dirty Old Men Sponsors - gay & straight
ponyman is offline   Reply With Quote
Reply


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

Forum Jump


All times are GMT -4. The time now is 01:19 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc