1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP question, instant money

Discussion in 'Hire a Freelancer' started by 730promo, Dec 8, 2010.

  1. 730promo

    730promo Junior Member

    Joined:
    Aug 27, 2009
    Messages:
    130
    Likes Received:
    12
    Occupation:
    Music Management and Marketing
    Location:
    Reading
    Home Page:
    Hi,
    Having problems with the PHP on my site. I will paypal $10 to the first person who can solve this very simple problem.

    I have a contact form and i want the email form to appear as sent from when the email is sent. See beneath for the code

    <?php $site_admin = 'info@730promo.com';

    // function ae_send_mail (see code above) is pasted here
    if(isset($_REQUEST['subcheck']) == "ys")
    { if($_POST['subject'] == "" || $_POST['name'] == "" || $_POST['message'] == "")
    {
    $false = true;
    }
    else
    {
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    // Additional headers
    $headers .= 'From: $_POST['email'], <'.$_REQUEST["name"].'>' . "\r\n";
    mail($site_admin, $_POST['subject'], $_POST['message'],$headers);
    $mail_send = true;
    }
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

    transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>730 Promo | Contact Us</title>
    <link type="text/css" href="css/style.css" rel="stylesheet" />
    <!--[if gte IE 7]>
    <link href="css/style_ie7.css" rel="stylesheet" type="text/css" />
    <![endif]-->
    <!--[if gte IE 8]>
    <link href="css/style_ie8.css" rel="stylesheet" type="text/css" />
    <![endif]-->
    <style type="text/css">
    img, div { behavior: url("iepngfix.htc") }
    </style>
    </head>

    <body>
    <!--header start-->
    <div id="wrapper">
    <!--top start-->
    <div id="top">
    <div id="top_inner"> <div id="main_menu">
    <ul>
    <li><a href="index.html" class="home"></a></li>
    <li><a href="aboutus.html" class="aboutus"></a></li>
    <li><a href="clients.html" class="clients"></a></li>
    <li><a href="services.html" class="services"></a></li>
    <li><a href="contact.html" class="contact_active"></a></li>
    </ul>
    </div>
    <div class="clear"></div>
    </div>
    <div class="clear"></div>
    </div>
    <!--top end-->

    <!--content start-->
    <div id="content">
    <!--content main start-->
    <div id="content_main">
    <!--banner start-->
    <div id="banner">
    <h1>Digital Marketing & Promotion company</h1>
    <div class="clear"></div>
    <p><span>Past and present clients</span><br />
    LLOYD BANKS (G-UNIT) | SWAY | LEVI ROOTS | LOWKEY  | S.A.S | <br />
    MARVELL | KLASHNEKOFF | STYLAH | SKANDAL</p>
    <div class="clear"></div>
    <div id="learn"><a href="aboutus.html"><img src="images/learnmore.png" width="132" height="35"

    alt="Learn More"/></a></div>
    </div>
    <!--banner end-->

    <!--contact start-->
    <div id="contact">
    <div id="contact_title">
    <h2><span>Contact us</span></h2></div>
    <div id="contact_body">
    <div class="service_category">
    <p class="service_title"><span class="address"><strong>Email</strong>:

    info@730promo.com</span></p>
    <p class="service_title"> </p>
    <p class="service_title"> </p>
    <p class="service_title">Phone : +44 (0)7794043670</p>
    <div class="clear"></div>
    </div>
    <?php
    if (isset($mail_send)) {
    echo "<p style='margin:100px 0 0 15px; color:#606060; text-align:center;

    font-weight:bold; font-size:18px;'>Form has been submitted. Thank You!</p>";
    }
    else {
    if($false == true)
    {
    echo "<p style='margin:15px 0 0 15px;'><span style='color:#F00; text-

    align:left; font-weight:bold;'>All fields are required</span></p>";
    }
    ?>

    <form name="contact_frm" id="contact_frm" action="" method="post" >
    <p class="service_title">Contact Form</p>
    <p> </p>
    <table width="600" border="0" cellspacing="10" cellpadding="5">
    <tr>
    <td width="133"><strong>Your Name *</strong></td>
    <td width="417"><input class="text" type="text" name="name"

    id="name" value="<?php echo $_POST['name'];?>"></td>
    </tr>
    <tr>
    <td><strong>Subject *</strong></td>
    <td><input class="text" type="text" name="subject" id="subject"

    <?php echo $_POST['subject'];?> ></td>
    </tr>
    <tr>

    <td><strong>Email Address *</strong></td>
    <td><input class="text" type="text" name="email" id="email" <?php echo $_POST['email'];?> ></td>
    </tr>

    <tr>
    <td><strong>Your Message *</strong></td>
    <td><textarea cols="40" rows="6" name="message" id="message" <?php

    echo $_POST['message'];?>></textarea>
    <input type="hidden" name="subcheck" value="ys" />
    </td>
    </tr>
    <tr>
    <td> </td>
    <td> </td>
    </tr>
    <tr>
    <td> </td>
    <td><a href="javascript:submitform()"><img

    src="images/submit_btn.gif" width="64" height="27" alt="Submit"/></a>   <a

    href="javascript:resetform()"><img src="images/reset_btn.gif" width="64" height="27" alt="Reset"/></a></td>
    </tr>
    </table>
    </form>
    <?php } ?>

    <div class="clear"></div>
    </div>
    <div id="contact_btm"><img src="images/round_btn.png" alt="border"/></div>
    </div>
    <!--overview end-->

    <!--casestudy start-->
    <!--casestudy end-->
    <div class="clear"></div>
    </div>
    <!--content main end-->

    <!--footer start-->
    <div id="footer">
    <div id="social_icons">
    <p>Find Us On</p>
    <p class="icons"><img src="images/social_icons.png" width="46" height="20" border="0"

    usemap="#Map" alt="Social Icons"/>
    <map name="Map" id="Map">
    <area shape="rect" coords="0,0,18,19" href="http://www.facebook.com/730promo"

    alt="Facebook" />
    <area shape="rect" coords="24,0,46,20" href="http://wwww.twitter.com/730promo"

    alt="Twitter" />
    </map>
    </p>
    </div>
    <div id="footer_menu">
    <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="aboutus.html">About Us</a></li>
    <li><a href="clients.html">Clients</a></li>
    <li><a href="services.html">Services</a></li>
    <li class="last"><a href="contactus.html">Contact Us</a></li>
    </ul>
    </div>
    </div>
    <!--footer end-->
    </div>
    <!--content end-->
    </div>
    <!--header end-->
    </body>
    </html>
    <script>
    function submitform()
    {
    document.getElementById('contact_frm').submit();
    }
    function resetform()
    {
    document.getElementById('name').value="";
    document.getElementById('subject').value="";
    document.getElementById('message').value="";
    }
    </script>
     
  2. syfenx

    syfenx Newbie

    Joined:
    Feb 3, 2009
    Messages:
    17
    Likes Received:
    0
    the code didn't work when I tried it... so i changed this

    Code:
    $headers .= "From:" .$_POST['email'].",<".$_REQUEST["name"].'>' . "\r\n";


    and when I submit the form...

    Code:
    <?php
    if (isset($mail_send)) {
    echo "<p style='margin:100px 0 0 15px; color:#606060; text-align:center; 
    
    font-weight:bold; font-size:18px;'>Form has been submitted. Thank You!</p>";
    }
    else {
    if($false == true)
    {
    echo "<p style='margin:15px 0 0 15px;'><span style='color:#F00; text-
    
    align:left; font-weight:bold;'>All fields are required</span></p>";
    }
    ?>

    this is what you see...

    now was the problem that the script wasn't working at all? because it seems to work now... I just don't have a mail server set up...

    if you need any more help let me know on aol prilibriator
     
  3. syfenx

    syfenx Newbie

    Joined:
    Feb 3, 2009
    Messages:
    17
    Likes Received:
    0
    I can't pm yet but my paypal is syfenx at gmail daut calm

    let me know if you need help with anything else, i'll try my best
     
    Last edited: Dec 8, 2010
  4. arasferra

    arasferra Registered Member

    Joined:
    Nov 5, 2009
    Messages:
    99
    Likes Received:
    13
    Find the line that says
    <div id="contact_body">

    Under it paste,
    <?PHP
    if ($mail_send) {
    echo 'Thank you, your mail is sent';
    }
    ?>
     
  5. redstone.1337

    redstone.1337 BANNED BANNED Jr. VIP Premium Member

    Joined:
    Dec 30, 2009
    Messages:
    1,259
    Likes Received:
    999
    mail($site_admin, $_POST['subject'], $_POST['message'],$headers);
    $mail_send = true;

    The second line here is wrong as it will assign value of true to $mail_send even if the mailing fails, so their is no point to do so. Change these to:

    if(mail($site_admin, $_POST['subject'], $_POST['message'],$headers)) {

    echo "Email successfully sent!";

    }

    or to spice up, give a javascript alert:

    if(mail($site_admin, $_POST['subject'], $_POST['message'],$headers)) {

    echo "<script type='text/javascript'> alert('Email successfully sent!'); document.location = 'page you want the user to send to after he clicks ok on the alert box';</script>";

    }