pranshu82202 Posted September 2, 2011 Share Posted September 2, 2011 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...??? Quote Link to comment https://forums.phpfreaks.com/topic/246287-html-with-php/ Share on other sites More sharing options...
AyKay47 Posted September 2, 2011 Share Posted September 2, 2011 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 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/246287-html-with-php/#findComment-1264788 Share on other sites More sharing options...
flappy_warbucks Posted September 2, 2011 Share Posted September 2, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246287-html-with-php/#findComment-1264789 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.