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 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2005
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    working in IE and not in firefox

    i got a form to upload infos and pics in my database


    HtmlT.php
    PHP Code:
    include("config.inc.php");
    include(
    "funcionsT.inc.php");
    .
    .
    .
    <
    body>
    <
    form enctype='multipart/form-data' action'$action' method='post' name='upload_form'>
    .
    .
    .
    <
    input name="artist" type="text" size="34" value $_POST[artist] >
    .
    <
    input name="song" type="text" size="34" value $_POST[song] >
    .
    <
    input name="label" type="text" size="34" value =$_POST[label]>
    .
    <
    input name="serial" type="text" size="34" value =$_POST[serial]>
    .
    .
    .
    <
    input name="Submit" type="submit" class="style5" value="Submit your infos"
    as you can see i m using
    <form enctype='multipart/form-data' action= '$action' method='post' name='upload_form'>

    this variable is defined by funcionsT.php
    so if no errors to set action=uploadT.php
    and if there are errors action=HtmlT.php so the user correct the input

    funcionT.php

    PHP Code:
    if(isset($Submit)){
        
    $error_msg='';
        if (
    trim($artist)=='' ) {
            
    $error_msg.="<li>Please enter a <strong>Artist/Band Name </strong>max 30 max char long </li>";
        }
        if ( 
    strlen(trim($artist)) > 30 || ereg('[^[:space:]a-zA-Z0-9_.-]{1,}'$artist)) {
            
    $error_msg.="<li> No special characters allowed in <strong>Artist/Band Name </strong></li>";
        }
        if (
    trim($song)=='' ) {
            
    $error_msg.="<li>Please enter a <strong>Album/Song Title </strong>max 30 max char long </li>";
        }
        if(
    trim($song)=='' || strlen(trim($song)) > 30 || ereg('[^[:space:]a-zA-Z0-9_.-]{1,}'$song)) {
            
    $error_msg.="<li>No special characters allowed in <strong>Album/Song Title </strong></li>";
        }
        if(
    trim($label)=='' || strlen(trim($label)) > 30 || ereg('[^[:space:]a-zA-Z0-9_.-]{1,}'$label)) {
            
    $error_msg.="<li>Please enter a <strong>Label </strong>max 30 max char long No special characters</li>";    
        }
        if(
    trim($serial)=='' || strlen(trim($serial)) > 30 || ereg('[^[:space:]a-zA-Z0-9_.-]{1,}'$serial)) {
            
    $error_msg.="<li>Please enter a <strong>Serial No </strong>max 30 max char long No special characters</li>";        
        } 
            
        
        
    // display error message if any, if not, proceed to other processing
        
    if($error_msg==''){
            
    $action 'uploadT.php';
        } else {
             
    $action 'HtmlT.php';
             
    $valid_error "<ol><font color=red>$error_msg</font></ol>";
        }


    i dont know if this is the best way to do this but working fine in IE.

    But in Firefox working only if i set the fields in order.
    i mean that if i fill the field artist first and then the song etc.. the form working as expected.

    if i set the 3 first fields and submit the form will display that the 4th field is empty.
    next if i fill the 4th field(missing)and delete the first field the form ignore my deletion and continue to submit.

    Any idead how to deal with this problem??

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    // display error message if any, if not, proceed to other processing 
        if($error_msg==''){ 
            $action = 'uploadT.php'; 
        } else { 
             $action = 'HtmlT.php'; 
             $valid_error = "<ol><font color=red>$error_msg</font></ol>"; 
        }
    I'm not sure why you are changing the form action on error or success.

    The usual way would be to output the error message to the page or a global error page

    e.g.
    if($err_msg != ""){
    header("Location: error.php?msg=$err_msg");
    }
    else{
    //ok
    }


  •  

    Posting Permissions

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