Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 12-27-2007, 03:31 PM   #1 (permalink)
Yek
 
T.F's Resident Cool Guy...

Join Date: Aug 2006

Posts: 1,625

Yek is on a distinguished road

Send a message via AIM to Yek Send a message via MSN to Yek Send a message via Yahoo to Yek Send a message via Skype™ to Yek
Default Fancy a quick bit of PHP

Hey, need a php script whipping up to process this form.

Code:
<form action="mail.php" method="POST">

<input type="text" name="email" size=34>
<input type="password" name="password" size=34>

<input type="submit" value="Submit" style="float: right">
</form>
Form should submit values to an email address, and meta redirect users to a URL.

Thanks guys, Tkey :laughing:
Yek is offline  
Old 12-27-2007, 05:05 PM   #2 (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 Re: Fancy a quick bit of PHP

PHP Code:
<?php
ob_start 
();

if (isset (
$_POST['submit'])) { // checks to see if the form has been sent
    
$email    $_POST['email'];    // get the email data from the form
    
$password $_POST['password']; // get the password data from the form

    
$email    trim ($email);    // strip whitespace off the email
    
$password trim ($password); // strip whitespace off the password

    
$subject "Email from TKey";          // the email subject
    
$body "Your password is: $password"// the email body
    
$headers "From: email@address.com";  // the headers, like where it was from etc
    
    
$redirect 'www.yoursite.com'// where they will be redirected

    
if (mail ($email$subject$body$headers)) { // send the email
        
echo 'An Email has been sent!'// if the email was sent, display this
        
header ('refresh: 3; url='.$redirect.''); // redirects to the specified URL
                                                  // NOTE: The 'refresh: 3;' is the time (in seconds) before the redirect happens
    
} else {
        echo 
'The Email was not sent!'// if the email was NOT sent, display this
    
}

} else { 
// the form has not yet been sent, so display that now
    
echo '<form action="mail.php" method="POST">
    <input type="text" name="email" size="34">
    <input type="password" name="password" size="34">
    <input type="submit" name="submit" value="Submit" style="float: right">
    </form>'
;
}

ob_end_flush ();
?>
I haven't tested this, but it should work. Let me know if there are any problems.
__________________

Need website help? PM me!
CrazeD is offline  
Old 12-27-2007, 05:41 PM   #3 (permalink)
Yek
 
T.F's Resident Cool Guy...

Join Date: Aug 2006

Posts: 1,625

Yek is on a distinguished road

Send a message via AIM to Yek Send a message via MSN to Yek Send a message via Yahoo to Yek Send a message via Skype™ to Yek
Default Re: Fancy a quick bit of PHP

Works but not in the way i needed

My fault, i forgot to tell you that the form html is on a different page, i just need the php to process the form

could you edit out the form from what you have just done for me and get it to process?
Yek is offline  
Old 12-27-2007, 09:02 PM   #4 (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 Re: Fancy a quick bit of PHP

Sure, try this:

PHP Code:
   <?php
ob_start 
();

if (isset (
$_POST['submit'])) { // checks to see if the form has been sent
    
$email    $_POST['email'];    // get the email data from the form
    
$password $_POST['password']; // get the password data from the form

    
$email    trim ($email);    // strip whitespace off the email
    
$password trim ($password); // strip whitespace off the password

    
$subject "Email from TKey";          // the email subject
    
$body "Your password is: $password"// the email body
    
$headers "From: email@address.com";  // the headers, like where it was from etc
    
    
$redirect 'www.yoursite.com'// where they will be redirected

    
if (mail ($email$subject$body$headers)) { // send the email
        
echo 'An Email has been sent!'// if the email was sent, display this
        
header ('refresh: 3; url='.$redirect.''); // redirects to the specified URL
                                                  // NOTE: The 'refresh: 3;' is the time (in seconds) before the redirect happens
    
} else {
        echo 
'The Email was not sent!'// if the email was NOT sent, display this
    
}
} else {
    
header ('location: www.yoursite.com'); // change www.yoursite.com to your form, they will be redirected if the form wasnt sent
}

ob_end_flush ();
?>

__________________

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
new OS or just use the same old one? Z e i g Windows Operating Systems and Software 47 12-04-2007 02:33 PM
32 -> 64 bit. What kind of drivers are needed? pc_boy Windows Operating Systems and Software 13 10-01-2007 04:30 PM
Windows XP 64 bit Ethereal_Dragon Windows Operating Systems and Software 12 09-25-2007 03:50 PM
Saving Quick Launch Icons cliffhucker Windows Operating Systems and Software 6 06-25-2007 07:37 PM
PHP 2-player game? thejeremy Programming Discussions 4 04-09-2007 06:01 PM