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-13, 10:28 AM   #1
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
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 11:30 PM.


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