Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Sep 2009
    Posts
    51
    Thanks
    29
    Thanked 0 Times in 0 Posts

    PLEASE HELP... any ideas :(

    This is my email php script below... my problem in when I insert value="name" into the name part of the form...

    if a user clicks "send" it recognises the name as "name"...

    is there any way of not accepting the name, "name", or the email, "email"?

    I hope you understand what i mean... I have attached a link of what I want it looks like... its just the registering of the name and email that doesn't work on my site...

    PHP Code:
    <?php
    if(isset($_POST['send'])){
    $to $_REQUEST['sendto'] ; // change all the following to $_POST
    $from $_REQUEST['Email'] ;
    $name $_REQUEST['Name'] ;
    $headers "From: $from";
    $subject "Web Contact Data";

    $fields = array();
    $fields{"Name"} = "Name";
    $fields{"Email"} = "Email";

    $body "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

    $headers2 "From: noreply@erbimages.com";
    $subject2 "Thank you for contacting us.";
    $autoreply "Thank you for contacting us. Somebody will get back to you as soon as possible, usually within 48 hours.";
        
    $send=false;
        if(
    $name == '') {$error"You have not entered your name, please try again.";}
        else {
        if(
    $from == '') {$error"You have not entered a valid email address, please try again.";}
        else {
        
    $send mail($to$subject$body$headers);
        
    $send2 mail($from$subject2$autoreply$headers2);
        }
        if(!isset(
    $error) && !$send)
            
    $error"We have encountered an error sending your mail, please notify service@erbimages.com"; }
    }
    // end of if(isset($_POST['send']))
    ?>    
        
        
        
                            <div class="index_register">
                                <li id="index_register_title">
                                <b>Register</b>
                                </li>
                                  <li><div id="section_error_li"><p>
                            <?php
                            
    if(isset($error))
                                echo 
    '<span id="section_error">'.$error.'</span>';
                            if(isset(
    $send) &&  $send== true){
                                echo 
    'Thank you, your message has been sent.';
                            }
                            if(!isset(
    $_POST['send']) || isset($error))
                            
    ?>
                                </div></p></li>
                                <li>
                            <form method="post" action="index.php">
                            <p><select name="sendto"><option value="info@erbimages.com">All News</option> <option value="info@erbimages.com">GN</option> <option value="hire@erbimages.com">GM</option> <option value="rf@erbimages.com">L&B</option> <option value="info@erbimages.com">ERB Images</option></select></p>
                            <p><font style="padding-right: 2em;">Name:</font><input size="14" maxlength="50" name="Name" value="Name"></p>
                            <p><font style="padding-right: 2em;">Email:</font><input size="14" maxlength="50" name="Email"></p>
                            <p id="index_register_send"><input type="submit" name="send" value="Send" id="register_send"></p>
                            </form> 
                            <?php
                            ?>
     
                                </li>

                            </div>

    http://www.stratreal.com

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,864
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    if a user clicks "send" it recognises the name as "name"...
    PHP Code:
    if($name == '' || $name=='name') {$error"You have not entered your name, please try again.";} 
    To validate email, you need to use a regexp match. Examples can be obtained from http://www.google.com/search?q=preg_...validate+email

    PS: You may enhance(this is just for helping users) your form by adding some javascript to remove the default values given to input elements. See http://www.codingforums.com/showthread.php?t=131094
    Last edited by abduraooft; 11-01-2009 at 02:58 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    lozbenson (11-01-2009)

  • #3
    New Coder
    Join Date
    Sep 2009
    Posts
    51
    Thanks
    29
    Thanked 0 Times in 0 Posts
    THANKS, THATS AWESOME...

    How would i incorporate:


    function check_email_mx($email2) {
    if( (preg_match('/(@.*@)¦(\.\.)¦(@\.)¦(\.@)¦(^\.)/', $email2)) ¦¦
    (preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}¦[0-9]{1,3})(\]?)$/',$email2)) ) {
    $host = explode('@', $email2);
    if(checkdnsrr($host[1].'.', 'MX') ) return true;
    if(checkdnsrr($host[1].'.', 'A') ) return true;
    if(checkdnsrr($host[1].'.', 'CNAME') ) return true;
    }
    return false;
    }

    into my page?


    THE OTHER THING I WOULD LOVE TO ASK AND BE HELPED WITH IS...

    is there a way or setting up how the noreply email will look when it is sent... i have tried with this:

    $autoreply = "Dear Mr Bohaimid,<br />Thank you for registering with www.erbimages.com.<br />To make sure that you continue to receive our email communications, we suggest that you add info@erbimages.com to your address book or Safe Senders list. In Microsoft Outlook, for example, you can add us to your address book by right clicking our address in the 'From' area above and selecting 'Add to Outlook Contacts' in the list that appears.<br />We look forward to you visiting the site, and can assure you that your privacy will continue to be respected at all times.<br />Yours sincerely,<br />ERB Images";

    but this does not work...
    Last edited by lozbenson; 11-01-2009 at 03:19 PM.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,864
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Try
    PHP Code:
    if(!preg_match("/^[[:alnum:]][a-z0-9_.'+-]*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$/",$from))
        
    $error="You have not entered a valid email address, please try again."
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    lozbenson (11-01-2009)

  • #5
    New Coder
    Join Date
    Sep 2009
    Posts
    51
    Thanks
    29
    Thanked 0 Times in 0 Posts
    ARHHH I am not sure I have done it correctly...

    It works to an extent but then it comes it with:

    You have not entered a valid email address, please try again.Thank you, your message has been sent.

    Heres what I have... is that right?

    PHP Code:
    <?php
    if(isset($_POST['send'])){
    $to $_REQUEST['sendto'] ; // change all the following to $_POST
    $from $_REQUEST['Email'] ;
    $name $_REQUEST['Name'] ;
    $headers "From: $from";
    $subject "Web Contact Data";

    $fields = array();
    $fields{"Name"} = "Name";
    $fields{"Email"} = "Email";

    $body "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

    $headers2 "From: noreply@erbimages.com";
    $subject2 "Thank you for contacting us.";
    $autoreply "Dear Mr Bohaimid,<br />Thank you for registering with www.erbimages.com.<br />To make sure that you continue to receive our email communications, we suggest that you add info@erbimages.com to your address book or Safe Senders list. In Microsoft Outlook, for example, you can add us to your address book by right clicking our address in the 'From' area above and selecting 'Add to Outlook Contacts' in the list that appears.<br />We look forward to you visiting the site, and can assure you that your privacy will continue to be respected at all times.<br />Yours sincerely.";
        
    $send=false;
        if(
    $name == '' || $name=='Name') {$error"You have not entered your name, please try again.";} 
        else {
        if(
    $from == '' || $from=='Email') {$error"You have not entered a valid email address, please try again.";}
        else {
        if(!
    preg_match("/^[[:alnum:]][a-z0-9_.'+-]*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$/",$from)) {$error="You have not entered a valid email address, please try again.";}
        
    $send mail($to$subject$body$headers);
        
    $send2 mail($from$subject2$autoreply$headers2);
        }
        if(!isset(
    $error) && !$send)
            
    $error"We have encountered an error sending your mail, please notify service@erbimages.com"; }
    }
    // end of if(isset($_POST['send']))
    ?>

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,864
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    PHP Code:
    if($from == '' || $from=='Email') {$error"You have not entered a valid email address, please try again.";}
        else {
        if(!
    preg_match("/^[[:alnum:]][a-z0-9_.'+-]*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$/",$from)) {$error="You have not entered a valid email address, please try again.";}
        
    $send mail($to$subject$body$headers);
        
    $send2 mail($from$subject2$autoreply$headers2);
        } 
    should be like
    PHP Code:
    if(!preg_match("/^[[:alnum:]][a-z0-9_.'+-]*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$/",$from)) $error"You have not entered a valid email address, please try again.";}
        else {
        {
        
    $send mail($to$subject$body$headers);
        
    $send2 mail($from$subject2$autoreply$headers2);
        } 
    You don't need to check against null in the case of email, as that regexp take cares of all
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    lozbenson (11-01-2009)

  • #7
    New Coder
    Join Date
    Sep 2009
    Posts
    51
    Thanks
    29
    Thanked 0 Times in 0 Posts
    Thanks so much... thats really GREAT...!!!



    Do you have any ideas regarding the no reply area?

  • #8
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    you need to set HTML headers to display html in emails

    i use

    PHP Code:
        
        $headers  
    'MIME-Version: 1.0' "\r\n";
        
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
        
    $headers .= 'From: Enquiries @ My Site <no-respond@mysite.com>' "\r\n";

        
    mail($sendto$subject$message$headers); /* change $sendto, $subject, $message accordingly */ 
    will need adapting slightly for your purpose.

  • Users who have thanked met for this post:

    lozbenson (11-01-2009)

  • #9
    New Coder
    Join Date
    Sep 2009
    Posts
    51
    Thanks
    29
    Thanked 0 Times in 0 Posts
    SORRY BUT I AM A NOVICE...

    what do I remove and where to I put that?


  • #10
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    PHP Code:
    // snip

    $subject2 "Thank you for contacting us.";
    $autoreply "<html><body><p>Dear Mr Bohaimid,</p><p>Thank you for registering with www.erbimages.com.</p>
    <p>To make sure that you continue to receive our email communications, we suggest that you add info@erbimages.com to your address book or Safe Senders list. </p>
    <p>In Microsoft Outlook, for example, you can add us to your address book by right clicking our address in the
    'From' area above and selecting 'Add to Outlook Contacts' in the list that appears.</p>
    <p>We look forward to you visiting the site, and can assure you that your privacy will continue to be respected at all times.</p><p>Yours sincerely.</p></body></html>"
    ;

        
    $headers2  'MIME-Version: 1.0' "\r\n";
        
    $headers2 .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
        
    $headers2 .= 'From: noreply@erbimages.com' "\r\n";

    mail($from$subject2$autoreply$headers2); 

  • Users who have thanked met for this post:

    lozbenson (11-01-2009)

  • #11
    New Coder
    Join Date
    Sep 2009
    Posts
    51
    Thanks
    29
    Thanked 0 Times in 0 Posts
    FANTASTIC...

    Is there anyway of making the name... where it now says Mr Bohaimid... to state the name that the person inserts?

    Also how to put a link in the autoreply??

    Thanks for all your help!!!

    Last edited by lozbenson; 11-01-2009 at 07:52 PM.

  • #12
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    PHP Code:
    // snip

    $subject2 "Thank you for contacting us.";
    $autoreply "<html><body><p>Dear " $name ",</p><p>Thank you for registering with <a href='http://www.erbimages.com'>ERB Images</a>.</p>
    <p>To make sure that you continue to receive our email communications, we suggest that you add <a href='mailto:info@erbimages.com'>info@erbimages.com</a> to your address book or Safe Senders list. </p>
    <p>In Microsoft Outlook, for example, you can add us to your address book by right clicking our address in the
    'From' area above and selecting 'Add to Outlook Contacts' in the list that appears.</p>
    <p>We look forward to you visiting the site, and can assure you that your privacy will continue to be respected at all times.</p><p>Yours sincerely.</p></body></html>"
    ;

        
    $headers2  'MIME-Version: 1.0' "\r\n";
        
    $headers2 .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
        
    $headers2 .= 'From: noreply@erbimages.com' "\r\n";

    mail($from$subject2$autoreply$headers2); 
    but if you have to ask that then you should probably look in to basic html...
    $autoreply is just a variable containing a string of text, which happens to be HTML. modify the HTML as required to change the appearance of the email when it is received by the user.

  • Users who have thanked met for this post:

    lozbenson (11-03-2009)

  • #13
    New Coder
    Join Date
    Sep 2009
    Posts
    51
    Thanks
    29
    Thanked 0 Times in 0 Posts
    Gotcha, thanks alot once again...

    I have been learning HTML and am now trying to get to grips with this kind of thing...

    I have been playing around for a while now on this and I wondered if there was a way, that when an error occurs it doesn't delete what they have inserted into the fields???



    Do you know of any codes???

    Thanks once again for before!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •