I am trying to create a ‘simple’ redirect for clients who use either WordPress or Indexhibit to manage there sites.
I have set it up to allow them to input their domain and have it redirect to the respective Admin areas (I am amazed at how many people forget but hey ho this is my solution)
I got it working fine for a single redirect but off the back of a previous SO submission tried to integrate both using if / elseif and it fails to Parse.
Any ideas what I have done wrong / help much appreciated!
<?php
if ($_POST['indexhibit_url']) {
if($_SERVER['REQUEST_METHOD'] == 'POST') : $indexhibit_url = $_POST['indexhibit_url']; header('Location: http://' . $indexhibit_url . '/ndxz-studio/');
}
elseif ($_POST['wordpress_url']) {
if($_SERVER['REQUEST_METHOD'] == 'POST') : $wordpress_url = $_POST['wordpress_url']; header('Location: http://' . $wordpress_url . '/wp-admin/');
}
?>
<form action="<?php echo $_SERVER['../PHP_SELF']; ?>" method="post" name="indexhibit_url">
<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 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="indexhibit_url" />
<input class="btn btn-info loginbuttons" name="index_submit" type="submit" value="Go" />
</form>
<form action="<?php echo $_SERVER['../PHP_SELF']; ?>" method="post" name="wordpress_url">
<h3 style='margin-top:2em;'>Wordpress</h3>
<p class='formp'>If your website is powered by <em>Wordpress</em> submit your URL to be forwarded to your admin area</p>
<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="wordpress_url" />
<input class="btn btn-info loginbuttons" name="wp_submit" type="submit" value="Go" />
</form>
<?php endif; ?>
you are mixing up ternary and non ternary operators:
just use normal if/else syntax:
and keep in mind that working with PHP_SELF like this it makes your code vulnerable to xss injections