Some confusing source I need help figuring out

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

Some confusing source I need help figuring out

Post by irishmike2004 »

I got the following code from a client, they state that it is PHP but I have never seen anything like this and having never seen ASP, that is what I believe it is. Anyhow, we want to make a redirect based on a form select dropdown and that should be the action (from what I can make out)... can someone help me to put the proper PHP code in place of whatever this is.

Thanks,

Code: Select all

<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#003366">
     <center>
  <table width="326" border="0" cellpadding="0" cellspacing="2" bordercolor="#999999">
    <tr>
      <td><span class="whitebold">How did you hear about us? </span> 
        <form action = "<%= Request.ServerVariables("SCRIPT_NAME")%>" method="post">
          <span class="linkswh"><br>
          <input type = "radio" name = "page" value = "search" >
          Online Search Engine<br>
          <input type = "radio" name = "page" value = "marty">
          Member<br>
          <input type = "radio" name = "page" value = "print">
          Print Media (newspaper, magazine, publication)<br>
          <input type = "radio" name = "page" value = "radio">
          Radio<br>
          <input type = "radio" name = "page" value = "tv">
          TV Advertisement</span><br>
          <br>
<input type = "submit" value = "continue >>">
</form>

<%
'get the users selection from the form
strURL = Request.Form("page")
'depending on the users selection redirect to that page
Select Case lcase(strURL)
Case "search"
Response.Redirect "/index.php"
Case "memeber"
Response.Redirect "/contact.php"
Case "print"
Response.Redirect "/faqs.php"
Case "radio"
Response.Redirect "/maintenance.php"
Case "tv"
Response.Redirect "/pc_repair.php"
End Select 
%></td>
    </tr>
  </table>
  </center>
</body>
</html>
Thanks for any help in advance.
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

-
??
I also have never seen asp, but if you know any website related coding, you know what the asp? does here and to redo the same in a switch clause and a new header.

djot
-
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

well, i dont know asp but it looks like thats what it is.

i would imagine this would be the php equivalent

Code: Select all

<?php

switch(strtolower($_POST&#1111;'page'])) &#123;

    case 'search':
        header('Location: index.php');
        break;
    case 'memeber':
        header('Location: contact.php');
        break;
// etc....
&#125;



?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yes it is asp, yes it is a simple switch statement with redirection.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Also, this part:

Code: Select all

<form action = "<%= Request.ServerVariables("SCRIPT_NAME")%>" method="post">
is the same as:

Code: Select all

<form action="<?=$_SERVER&#1111;'PHP_SELF'];?>"> method="post">
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

i've seen some php implementations of the Redirect class etc... but don't remember where ;)


probably http://asp2php.naken.cc/ is a good place to start :)
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

Thanks all

Post by irishmike2004 »

Hi Guys:

thanks for the help, think the suggestions worked out. Thanks for the help!
irishmike2004
Forum Contributor
Posts: 119
Joined: Mon Nov 15, 2004 3:54 pm
Location: Lawrence, Kansas

this works on my 5.0.3 but breaks on the clients 4.3 server

Post by irishmike2004 »

I am not sure if I understand why, but in reading the documentation, I assume it is because globals are off? Anyhow, below is my code as it works fine on PHP 5.0.3 on my machine but fails on the 4.3.x server it is meant to run on.

Code: Select all

<?php

$action = $_SERVER&#1111;'PHP_SELF'];

echo '
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#003366">
     <center>
  <table width="326" border="0" cellpadding="0" cellspacing="2" bordercolor="#999999">
    <tr>
      <td><span class="whitebold">How did you hear about us? </span> 
        <form action = "'.$action.'" method="post">
          <span class="linkswh"><br>
          <input type = "radio" name = "page" value = "search" >
          Online Search Engine<br>
          <input type = "radio" name = "page" value = "marty">
          Member<br>
          <input type = "radio" name = "page" value = "print">
          Print Media (newspaper, magazine, publication)<br>
          <input type = "radio" name = "page" value = "radio">
          Radio<br>
          <input type = "radio" name = "page" value = "tv">
          TV Advertisement</span><br>
          <br>
<input type = "submit" value = "continue >>">
</form>
</td>
    </tr>
  </table>
  </center>
</body>
</html>';

switch(strtolower($_POST&#1111;'page'])) &#123;

    case 'search':
        header('Location: index.php');
        break;
    case 'memeber':
        header('Location: contact.php');
        break;
    case 'print':
    	header('Location: faqs.php');
    	break;
    case 'radio':
    	header('Location: maintenance.php');
    	break;
    case 'tv':
    	header('Location: pc_repair.php');
    	break;
    
&#125; 


?>
we need to make this work with 4.3

Thanks again.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why not download the exact version their server uses, copy the ini they run under and figure it out from there?

The posted code should work without much issue.. but that depends on what the error is.. any clue?
Post Reply