Jump to content

html with php


pranshu82202

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

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.