Jump to content

Recommended Posts

I have an input converter. Basically, say I call "file.php?a=test1" well the "file.php" would run this:

 

<?php

if (isset($_GET['a'])) {

  $converter = array('blankspot' => 'blanks',
  'test1' => '123',
  'test2' => '321',
  'blankspothere' => 'blank');
  $a = $_GET['a']; 

  if (isset($converter[$a)) {
  
header("Location: $converter");

    exit;
  }
}

?>

 

That would just redirect me to "123". However...now I want to have 2 things that the input converts into. Example:

 

file.php?a=test1

That script gives it 2 converts like:

 

<?php

if (isset($_GET['a'])) {

  $converter = array('blankspot' => 'blanks',
  'test1' => $x=123 and $y=456,
  'test2' => $x=321 and $y=654,
  'blankspothere' => 'blank');
  $a = $_GET['a']; 

  if (isset($converter[$a)) {
  
header("Location: $x.$y");

    exit;
  }
}

?>

 

That would redirect to "123456"

 

I don't know how to give it 2 converts so my coding is wrong.

 

Help please?

Link to comment
https://forums.phpfreaks.com/topic/185957-input-converter/
Share on other sites

perhaps something like this..

$convX = array('test1'=>123,'test2'=>567);
$convY = array('test1'=>456,'test2'=>890);

if (isset($_GET['a']) && isset($convX[$_GET['a']]) && isset($convY[$_GET['a']])) {
$loc = $convX[$_GET['a']] . $convY[$_GET['a']];
header('Location: '.$loc);
} else {
//No redirect
}

 

Link to comment
https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-982417
Share on other sites

<?php
if (isset($_GET['a'])) {
  $converter = array('blankspot' => 'blanks',
  'test1' => array('x' => 123, 'y' => 456),
  'test2' => array('x' => 321, 'y' => 654),
  'blankspothere' => 'blank');

  $a = $_GET['a']; 

  if (isset($converter[$a])) {
if (is_array($converter[$a])) 
	header("Location: {$converter[$a]['x']}{$converter[$a]['y']}");
else
	header("Location: {$converter[$a]}");
    exit;
  }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-982418
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.