asp to php conversion - form handling

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
deltatango5
Forum Newbie
Posts: 14
Joined: Mon Jan 22, 2007 1:07 pm
Contact:

asp to php conversion - form handling

Post by deltatango5 »

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I'm fairly green in the exciting world of PHP ... I've been trying to convert this ASP code to PHP ... basically I have a "thankyou.php" page that requires 3 different responses depending on which form is submitted.  Below is the "current" ASP variation and I'm in hopes of finding a solution / expertise to make it PHP-able!  (3 different forms throughout site feed into this "thankyou.php" form/response page)

[syntax="asp"]<% if request.querystring("ls")="contact" then%>
<p>Thank you for your interest ..... response info number one.</p> 	
<% elseif request.querystring("ls")="signup" then%>
<p>Thank you for your interest ..... response info number two.</p> 
<% elseif request.querystring("ls")="jobs" then%>
<p>Thank you for your interest ..... response info number three.</p> 
<% end if%>
I appreciate all and any thoughts/help you may have and please remember I'm eagerly learning the ropes--with that--IF anyone has recommendations to PHP learning via DVD--I'm all ears!!

Thanks again!
Des




Everah | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Here is a more or less literal translation.. Up to you to lookup the missing bits (make sure to consult the http://www.php.net/docs if you have any doubts about the syntax etc...)

Code: Select all

// test if the parameter 'ls' exists in the query parameters
if (array_key_exists('ls', $_GET)) 
{
 // test if the parameter ls matches contact
 if ($_GET['ls'] == "contact") {
  ?>

    <p>Thank you for your interest ..... response info number one.</p>

  <?php
 } 
  // and so on... 
}
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You could use a switch also, if you were so inclinded.

Code: Select all

<?php
if (isset($_GET['ls']))
{
  $ls = $_GET['ls'];

  switch($ls)
  {
    case 'contact':
      echo '<p>Thank you for your interest ..... response info number one.</p>';
      break;

    case 'signup':
      echo '<p>Thank you for your interest ..... response info number two.</p>';
      break;

    case 'jobs':
      echo '<p>Thank you for your interest ..... response info number three.</p>';
      break;

    default:
      echo '<p>Please make a selection.</p>';
      break;
  }
}
?>
Or you can still use if statements:

Code: Select all

<?php
if (isset($_GET['ls']))
{
  $ls = $_GET['ls'];

  if ($ls == 'contact')
  {
    echo '<p>Thank you for your interest ..... response info number one.</p>';
  }
  elseif ($ls == 'signup')
  {
    echo '<p>Thank you for your interest ..... response info number two.</p>';
  }
  elseif ($ls == 'jobs')
  {
    echo '<p>Thank you for your interest ..... response info number three.</p>';
  }
}
?>
Post Reply