Jump to content

Recommended Posts

I ahve a php page passwordchange.php..

 

I want that if a user goes to url passwordchange.php?via=security_question

 

some html input fields will be shown

 

And when user goes to url passswordchange.php?via=previous_password

 

Some other input fields will be shown..

 

Basically i want to put a lot of html code in php's if statement

 

<?php
if($_GET['via']=="security_question")
// LOT OF HTML DATA
?>

<?php
if($_GET['via']=="previous_password")
// LOT OF HTML DATA
?>

 

How sould i use html inside php...???

 

Link to comment
https://forums.phpfreaks.com/topic/246287-html-with-php/
Share on other sites

1.you can either output it via php using either echo or print..

 

2. the method that I use is by switching from PHP to html like so..

 

<?php
if($_GET['via']=="security_question"){?>
<div>html test</div>
<?php } ?>

<?php
if($_GET['via']=="previous_password"){?>
<div>same thing here</div>
<?php } ?>

Link to comment
https://forums.phpfreaks.com/topic/246287-html-with-php/#findComment-1264788
Share on other sites

I would not use $_GET for that.  It would be to easy to trip the site up.  try:

 

<?php
switch($_GET['via'])
{
    case "security_question":
        // call a function that would handle this form
        security_question_form();
        break;
    case "previous_password":
        // call a function that would handle this other form
        previous_password_form();
        break;
    default: // incase someone tries to tweek the address bar vars.  the software won't go tit's up, it will default to this:
        go_default_option();
}

 

And then put all your HTML in separate functions.  It will make maintaining the code much easier.

Link to comment
https://forums.phpfreaks.com/topic/246287-html-with-php/#findComment-1264789
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.