redirect to page

A

Anonymous

Guest
Hi
I have form in my website, and all php actions are in separate file.

I would like print in div of my website message when my condition form actions file returns true. Something like that

php fie with actions for form :

Code:
      $file_name =    $_FILES['uploaded-file']["name"][$i];  

 	if ($_FILES['uploaded-file']['size'][$i] > $max_size) { 
 	$message =  $file_name .  "is too big";
 	//action here to remember/send   $message value;
 	
 	 header("Location:".$_SERVER[HTTP_REFERER]."#file-size-error");  //redirect to html element
                    die();
 	
 	
 	}

my index page ( I set htaccess to treat html as php)
Code:
                <div id ="file-size-error" class="file-error">

                    <?php
                        if(isset($_POST['message'])){   //print message from $message here
                        echo $_POST['message'];
}
                        ?>
                    
                </div>
 
Use the session:
https://gist.github.com/PphEight/e535a76955aec432dd4cbbf4b1dc5b54
You can use session_set_message during validating the form data and show the message while generating the page layout
 
Back
Top