Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
79
rated 0 times [  84] [ 5]  / answers: 1 / hits: 5606  / 10 Years ago, thu, august 28, 2014, 12:00:00

i need to stay on the same page so i'm not using submit button. How can i go to php page and send form values?
exempel:



 <form action= method=post enctype=multipart/form-data>
<label for=file>Filename:</label> <input type=file name=csv id=csv/>
<input type= button value=immport onClick = window.location.href =readFile.php'
.(this.form); >
</form>


this doesn't work. other options?


More From » php

 Answers
7

If you don't want to use an AJAX call (?... see comments), There is a classic way to submit your form, but this results in reloading the actual page:



The form is in the same script as the logic is. In your case, that would be readFile.php.



Use the $_SERVER['PHP_SELF'] as form action:



<form action=<?php echo $_SERVER['PHP_SELF'] ?> method=post enctype=multipart/form-data>
<label for=file>Filename:</label> <input type=file name=csv id=csv/>
<input type= submit value=immport />
</form>


The form will be submitted to the actual page. From the docs:




$_SERVER is an array containing information such as headers, paths,
and script locations.



...



'PHP_SELF' The filename of the currently executing script, relative to
the document root....



[#42832] Wednesday, August 27, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
carlymykalac

Total Points: 740
Total Questions: 91
Total Answers: 91

Location: Sudan
Member since Thu, May 7, 2020
4 Years ago
;