APD1993 Posted May 30, 2012 Share Posted May 30, 2012 I'm trying to implement a simple submit button within a PHP script so that when it is clicked, the user goes back to the homepage. However, at the moment my coding does not work. Any ideas on how to solve this? My code at the moment is: <?php //Creating a variable that essentially is used to make sure that the file being created by the user will be named based on what they entered into the text box called filename that collected the Client's Surname they gave in the fileupload.html page and that the new, user created file will be stored in the RCM3 folder and will be stored in an HTML format $filename="C:/xampp/htdocs/RCM3/".$_POST['filename'].".html"; //Getting the car accident information from the text box named info on the fileupload.html page and using it as the content for the user created file $info=$_POST['info']; //Opening the file (by using the fopen function) and giving append and write permissions for the file $file=fopen($filename, 'a+w'); //Putting in the user created file name and the accident details into the new file by using the fputs function fputs($file, $info); //Closing the file and ending the editing of the file name and file contents by using the fclose function fclose($file); ?> <html><head><title>Creating An Accident Report Form</title></head> <body> <?php //Using an IF statement so that if the file has successfully been created, the file details (name, filepath and file size) will be displayed to the user, as well as a submit button that takes the user back to the RCM Homepage--> if(file_exists($filename)){ $file_length=filesize($filename); $msg = "<p>File created: $filename<br>"; $msg.="File size: $file_length bytes<br></p>"; //INSERT SUBMIT BUTTON HERE $msg.="<form action="Congrats.html" method="post" input type="submit" value="Go back to RCM Homepage"></form> echo ($msg); } //If the file does not exist, then an error message will appear telling the user that file was not able to be created. A submit button will also be in place so that the user can go back to the RCM Homepage if they so choose else { echo("Unable to create file"); } ?> </body> </html> Any help is appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/263393-how-can-i-implement-html-buttons-in-a-php-script/ Share on other sites More sharing options...
wigwambam Posted May 30, 2012 Share Posted May 30, 2012 I see a problem with this line $msg.="<form action="Congrats.html" method="post" input type="submit" value="Go back to RCM Homepage"></form> Should be: $msg.="<form action=\"Congrats.html\" method=\"post\" input type=\"submit\" value=\"Go back to RCM Homepage\"></form>"; Don't think this is enough to fix your problem though... You have nothing in your <form></form> Quote Link to comment https://forums.phpfreaks.com/topic/263393-how-can-i-implement-html-buttons-in-a-php-script/#findComment-1349845 Share on other sites More sharing options...
Pikachu2000 Posted May 30, 2012 Share Posted May 30, 2012 All on one line: You're using unescaped double quotes in a double-quoted string, which is then not closed with an ending double quote, and not terminated with a semicolon. Your opening form tag isn't closed with >, and your input element for the submit button isn't opened with <. Quote Link to comment https://forums.phpfreaks.com/topic/263393-how-can-i-implement-html-buttons-in-a-php-script/#findComment-1349850 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.