Reputation: 425
I have a form on the inside template of WordPress.
<?php
/*
Template Name: Template Form Submission
*/
get_header(); ?>
<div class="entry-content">
<div style="width: 1000px;" align="left">
<form enctype="multipart/form-data" name="file_uplaod" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="name" id="name" /><br /><br />
<input type="text" name="email" id="email" /><br /><br />
File <input type="file" name="test_file" id="test_file"/><br /><br />
<input type="submit">
</form>
</div>
But the problem is PHP-SELF is not working after form submission and it is going to index.php page. I am unable to use Javascript Redirect as File Upload is here. So can anybody help me to solve it.
Upvotes: 1
Views: 156
Reputation: 801
I believe you can just omit the action from the form tag to submit to your current url. If wordpress SEO urls are active then $_SERVER['PHP_SELF'] will resolve to index.php.
Upvotes: 0
Reputation: 12327
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
then replace
<form enctype="multipart/form-data" name="file_uplaod" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
with
<form enctype="multipart/form-data" name="resume_uplaod" action="<?php echo curPageURL(); ?>" method="post">
See http://dev.kanngard.net/Permalinks/ID_20050507183447.html
Upvotes: 2