Jump to content

Input converter


Graxeon

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.