www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: Email validation on submit

  1. #16
    Join Date
    Jan 2009
    Posts
    3,346
    Use SESSIONs.

    PHP Code:
    $_SESSION['errMsg'][] = "Invalid Email Address"//add array of messages to the session 
    PHP Code:
    if(isset($_SESSION['errMsg']) && is_array($_SESSION['errMsg']))  {
    echo 
    "<div class=\"msg\">";
          foreach (
    $_SESSION['errMsg'] as $e) {
            echo 
    "* $e <br>";
            }
          echo 
    "</div>";    
    unset(
    $_SESSION['errMsg']); //clear the variable from session       

    One thing to keep in mind is that each page will need a "session_start();" at the top in order for this to work.

  2. #17
    Join Date
    Jun 2011
    Posts
    141
    Quote Originally Posted by tobias.wagner View Post
    Like this

    PHP Code:
    echo $_GET['msg']; 
    Sorry for my lack of knowledge on this but where exactly do I put that? Just where I want the message to appear? And delete the rest of the code I had in there?

  3. #18
    Join Date
    Apr 2012
    Posts
    15
    PHP Code:
    $err $_GET['msg']; 
    You would also need to remove foreach loop, as it can be used for an array only. And as you changed it from array $err[] to variable $err use simple echo command

    PHP Code:
    if(!empty($err))  {
    echo 
    "<div class=\"msg\">";
            echo 
    "* $err  <br>";
          echo 
    "</div>";    
           } 

  4. #19
    Join Date
    Jun 2011
    Posts
    141
    OK so I have put
    Code:
    <?php
    if(!empty($err))  {
    echo "<div class=\"msg\">";
            echo "* $err  <br>";
          echo "</div>";    
           }
    ?>
    where I want the error to appear but still unsure where your $err = $_GET['msg']; or echo $_GET['msg']; goes

  5. #20
    Join Date
    Apr 2012
    Posts
    15
    You can place it anywhere before that piece of code, like this

    PHP Code:
    $err $_GET['msg']; 

    if(!empty(
    $err))  {
        echo 
    "<div class=\"msg\">";
        echo 
    "* $err  <br>";
        echo 
    "</div>";    

    or do it like this

    PHP Code:
    if(!empty($_GET['msg']))  {
        echo 
    "<div class=\"msg\">";
        echo 
    "* " $_GET['msg'] . "  <br>";
        echo 
    "</div>";    


  6. #21
    Join Date
    Jun 2011
    Posts
    141
    Brill, thank you for all your help, youve been excellent!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles