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 9 of 9

Thread: If cycle help

  1. #1
    ggp
    ggp is offline
    New Coder
    Join Date
    Nov 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If cycle help

    Hi.
    Could you help me plzz?
    This code is not doing the cicle properly it is not going into the else to inserting the data in the db and to validate the email.
    Thanks for any help

    PHP Code:
    <?php
    include 'global2.php';
    if (isset(
    $_POST['submit'])) {
       
    //perform any error checking on incoming data
       
       
    if (empty($name) || empty($email) || empty($subject) || empty($message)){
    echo 
    "****   .";
    exit();
    }

     else {
     if (!empty(
    $_POST['image_id']))       
     {}
     else
        {
           
          
    $date=time();

          
    mysql_query("INSERT INTO contactus (name, email, subject, message) VALUES('{$_POST['name']}',  '{$_POST['email']}' ,  '{$_POST['subject']}',  '{$_POST['message']}')");
          
    $message 'Thank You for your email will be in touch with you shortly'

    }

    ?>
    <?
    if (isset($****)) print $****>
    <?
    php
    $from 
    $_REQUEST['****'];
    // is the $from email address in valid format?
    if(eregi("(   )"$from)) {
    print 
    $name;
    print 
    $email;
    print 
    $subject;

    } else {
      print(
    "Sorry, this email address:  doesn't seem to be in the right format.");
    }      
    }
    }

    ?>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Add error checking to your query.

  • #3
    ggp
    ggp is offline
    New Coder
    Join Date
    Nov 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry. I do not what could I use for error checking. Can you tell me?

    Thank you.

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Quote Originally Posted by ggp View Post
    PHP Code:
    <?if (isset($****)) print $****>
    That line is going to cause an error. You need to be more specific, what is not executing exactly? Are your form variables the same name as your $_POST variables? ie. <input name="submit" /> $_POST['submit']

  • #5
    ggp
    ggp is offline
    New Coder
    Join Date
    Nov 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is what I do have in the form.
    What is not executing is:
    When I submit the form with all the fields it does not give me the message:
    Thank You for your email will be in touch with you shortly. Also does not insert the info in the db.

    Whe I submit the form with a wrong email it does not displays:
    print("Sorry, this email address: doesn't seem to be in the right format.");

    Thanks for any help.

    [HTML]
    PHP Code:
    <form method="post" action="eemail.php">
    <
    table width="100%" border="1" cellspacing="0" cellpadding="3">
    <
    tr
    <
    td width="20%">Name:</td>
    <
    td width="80%"><input name="name" type="text" size=45 maxlength=80 </td>
    </
    tr>

    <
    tr
    <
    td width="20%">Email:</td>
    <
    td width="80%"><input name="**" type="text" size=45 maxlength=80 ></td>
    </
    tr>

    <
    tr
    <
    td width="20%">Subject:</td>
    <
    td width="80%"><input name="subject" type="text" size=45 maxlength=80 ></td>
    </
    tr>

    <
    tr
    <
    td width="20%">Message:</td>
    <
    td width="80%"><textarea name="message" wrap="VIRTUAL" rows=5 cols=40></textarea></td>
    </
    tr>

    <
    tr>
    <
    td> </td>
    <
    td>
       
       <
    input type="submit" name="submit" value="Send Email"></td>
       
    </
    tr>
    </
    table></form>
    [/
    HTML

    EEMAIL.PHP:

    PHP Code:
    <?php 
    include 'global2.php'
    if (isset(
    $_POST['submit'])) { 
       
    //perform any error checking on incoming data 
        
       
    if (empty($name) || empty($email) || empty($subject) || empty($message)){ 
    echo 
    "****   ."
    exit(); 


     else { 
     if (!empty(
    $_POST['image_id']))        
     {} 
     else 
        { 
            
          
    $date=time(); 

          
    mysql_query("INSERT INTO contactus (name, email, subject, message) VALUES('{$_POST['name']}',  '{$_POST['email']}' ,  '{$_POST['subject']}',  '{$_POST['message']}')"); 
          
    $message 'Thank You for your email will be in touch with you shortly';  



    ?> 
    <?if (isset($****)) print $****> 
    <?
    php 
    $from 
    $_REQUEST['****']; 
    // is the $from email address in valid format? 
    if(eregi("(   )"$from)) { 
    print 
    $name
    print 
    $email
    print 
    $subject

    } else { 
      print(
    "Sorry, this email address:  doesn't seem to be in the right format."); 
    }       



    ?>

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    What is a cicle?
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    ggp
    ggp is offline
    New Coder
    Join Date
    Nov 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry. what I mean is the If{ } else{ }

  • #8
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Hey Spookster don't you know it's how people are spelling cycle these days! But don't get on anyone's case about spelling, it's just "internet spelling". Nevermind the fact that we can't read it...

  • #9
    ggp
    ggp is offline
    New Coder
    Join Date
    Nov 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the correction. And any help for the thread.


  •  

    Posting Permissions

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