redirect to page

Links for php scripts

Moderators: gesf, Michalio

Post Reply

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: Select all

      $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

my index page ( I set htaccess to treat html as php)

Code: Select all

                <div id ="file-size-error" class="file-error">

                        if(isset($_POST['message'])){   //print message from $message here
                        echo $_POST['message'];

User avatar
Posts: 339
Joined: Sun Jul 18, 2021 1:33 pm
Location: Poland

Use the session:
You can use session_set_message during validating the form data and show the message while generating the page layout
Free coding lessons:
Post Reply