0

I do a few websites for clients using either Indexhibit or Wordpress. I keep getting the same 'where do I login?' email from them so want to create a simple forward form on my site where a client can enter there URL, select either Wordpress/Indexhibit and click go and be forwarded on to there site.

I have constructed the following after some googling:

<?php if($_SERVER['REQUEST_METHOD'] == 'POST') : $siteid1 = $_POST['siteid1'];             header('Location: http://' . $siteid1 . '/ndxz-studio/'); else:?>
<form action="<?php echo $_SERVER['../PHP_SELF']; ?>" method="post">
<h3>Indexhibit</h3>
<p class='formp'>If your website is powered by <em>Indexhibit</em> submit your URL to be forwarded to your admin area</p>
<input  input class='loginforms' type="text"  value='i.e. your-domain-name.com' onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'i.e. your-domain-name.com':this.value;"   name="siteid1" />
<input class="btn btn-success loginbuttons" type="submit" value="Go" />
</form>
<?php endif; ?> 

And then the same again directly beneath it for Wordpress.

However because I am using

<?php if($_SERVER['REQUEST_METHOD'] == 'POST') : $siteid1 = $_POST['siteid1'];             header('Location: http://' . $siteid1 . '/ndxz-studio/'); else:?>

It only seems to take accept one form on the site. (so either indexhibit fails to go to /ndxz-studio or wp fails to go to wp-admin)

PHP is not my forte so apologies I have committed any stupid mistakes

4

1 回答 1

3

正因为如此:

<?php if($_SERVER['REQUEST_METHOD'] == 'POST') : $siteid1 = $_POST['siteid1']; 

这在你的形式中总是正确的。所以,PHP 执行它。PHP 永远不会到达第二if条语句,因此它永远不会执行。

尝试一个if else语句并确保您的表单名称是唯一的

编辑:

这是一些示例代码,可帮助您入门。

if($_POST['siteid1']) {
    $siteid1 = $_POST['siteid1']; 
    // execute code here
} elseif($_POST['siteid2']) {
    $siteid1 = $_POST['siteid1'];
    // Execute code here
}
于 2012-04-26T18:43:05.157 回答