wmguk Posted October 21, 2008 Share Posted October 21, 2008 Hi, I have a form field which takes any input and passes the input to a php script, what I need is a javascript prompt so if the form input is ABC it prompts for a pin number, and then both the inputs are passed to php page, however if the input is anything other than ABC it doesnt run a prompt... Is there a way of doing this as a pop up prompt box rather than just passing to a php page that says if ($var =- "ABC"){ //INSERT POP UP PROMPT HERE } else { //JUST CARRY ON } etc.... Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/ Share on other sites More sharing options...
MadTechie Posted October 21, 2008 Share Posted October 21, 2008 This sounds like a javascript question.. i think.. i am not sure what your asking!! Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/#findComment-671319 Share on other sites More sharing options...
Maq Posted October 21, 2008 Share Posted October 21, 2008 This sounds like a javascript question.. i think.. i am not sure what your asking!! me either @wmguk in your subject you have "JS prompt for input to work with PHP", so i believe this belongs in the javascript section. But yes you can check with PHP and if($var == "ABC") { // your javascript pop up code } else { // go to next page or w/e } We need to see your current code where you want to do this. Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/#findComment-671324 Share on other sites More sharing options...
wmguk Posted October 21, 2008 Author Share Posted October 21, 2008 at the moment there is no code, I simply have a form with an input, that goes to a php script to verify if the code entered is authorised. If I use php then I will have to have a secondary script, so that if code = ABC then prompt for a pin number... then if the pin and code is authorised then show the page, but what I wanted to do was show a javascript prompt popup for the pin if the code entered was ABC... that way getting rid of the middle php code I'm sure I havent described this well but its the only way I can describe it really ENTER CODE -> IF ABC the prompt for PIN, Else -> VERIFY THE INFO AND SHOW THE PAGE Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/#findComment-671333 Share on other sites More sharing options...
Maq Posted October 21, 2008 Share Posted October 21, 2008 How is it submitted? A button with $_POST for example... Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/#findComment-671336 Share on other sites More sharing options...
wmguk Posted October 21, 2008 Author Share Posted October 21, 2008 oh sorry, I should have said that!!!! yes its a standard form and button <form name="verify" action="script.php" method="post"> <input name="albumid" type="text" > <input name="contact" type="submit" value="Contact Us" > Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/#findComment-671337 Share on other sites More sharing options...
MadTechie Posted October 22, 2008 Share Posted October 22, 2008 Okay the part i dont get is.. wouldn't you have the javascript prompt you for a security code when "code = ABC" remember i have no idea what code refers to or if ABC is unique to each user or what.. i really need more info.. from what i am reading you enter a code if thats equal to abc you ask for a PIN.. if ABC is static then why submit it.. why not have a JS to add the form element ? if its not static you could use AJAX to validate it Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/#findComment-671352 Share on other sites More sharing options...
wmguk Posted October 22, 2008 Author Share Posted October 22, 2008 ah ok, its a photography site, most people dont require a "pin" code, so you just enter the album name... ie. if it is a wedding then you would just enter SmithJ for John Smiths wedding photo's.... however recently lots of school pics have been added and there is one album name, but the pin code ensures you only see your own childs photos, and obviously people who shouldnt look at school kiddies cant get access.... so basically ABC is the code for the school (all the parents get this info) - so if albumid = ABC then prompt for the pin code.... then the pin code is checked with the database to show the correct picture.. Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/#findComment-671360 Share on other sites More sharing options...
MadTechie Posted October 22, 2008 Share Posted October 22, 2008 I guess you could do something like this:~ its just a draft (very quickly written) <?php $SomeData = ""; $RequirePIN = false; if(!empty($_POST['SomeData'])) { //Check if PIN is Req. if($_POST['SomeData'] == "Private") { $RequirePIN = true; } if(!$RequirePIN) { header("LOCATION: display.php?SomeData=".$_POST['SomeData']); } if($RequirePIN && !empty($_POST['PIN'])) { $_SESSION['PIN'] = $_POST['PIN']; //display.php MUST also check the Database PIN with the $_SESSION['PIN'] header("LOCATION: display.php?SomeData=".$_POST['SomeData']); exit; } $SomeData = $_POST['SomeData']; } ?> <form method="POST"> <input type="text" name="SomeData" value="<?php echo $SomeData ?>"> <?php if($RequirePIN) { ?> <input type="text" name="PIN" value="123"> <?php } ?> <input type="submit" value="Submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/#findComment-671373 Share on other sites More sharing options...
wmguk Posted October 22, 2008 Author Share Posted October 22, 2008 ok, i see where you are going with that, and yes thats true, it would take out the need for an extra check within the script.php page, however I just like the look of a javascript prompt popup.... but I can certainly play with the code you have given me, drop the idea of JS and just go with pure php authorisation... Quote Link to comment https://forums.phpfreaks.com/topic/129480-js-prompt-for-input-to-work-with-php/#findComment-671377 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.