Problem With Prompt Box And PHP - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Problem With Prompt Box And PHP (649 Views)
| Problem With Prompt Box And PHP by walterjnr(op): 10:48pm On May 02, 2020 |
Please i have an issue comparing value from Prompt box to database (like Login ) i can't pass variable from Javascript in loader.php to a variable in btwc_authenticate.php. please. This is my code: Loader.php <script> function myFunction() { var newVal = prompt("Please enter your BWTC:" ;if (newVal === "" {alert("Empty entry! Try again " ;} else if (newVal) { // user typed something and hit OK window.location.href = "btwc_authenticate.php?newVal='+newVal+'"; } else { // user hit cancel } } </script> btwc_authenticate.php <?php session_start(); //error_reporting(0); include('../includes/config.php'); //$newVal = +newVal+ ; $newVal =$_POST['newVal']; $sql = "SELECT * from transfer_code WHERE BWTC=:BWTC"; $query = $dbh->prepare($sql); $query-> bindParam(':BWTC', $newVal, PDO::PARAM_STR); $query->execute(); $results=$query->fetchAll(PDO::FETCH_OBJ); if($query->rowCount() > 0) { $_SESSION['sess_newVal']=$newVal; header("location:loader_2.php" ;}else{ ?> <script> alert('BTWC PIN Not Correct '); window.location = "loader.php"; </script> <?php } ?> pls help. thanks |
| Re: Problem With Prompt Box And PHP by Kingpinukecy(m): 11:31pm On May 02, 2020 |
Bros from what i saw , i understan u small. Sore, what u need to do is to include that btwc_auth page in ur loader.php page and then select the data u want to compare with newval and store dat data in a variable the u do somthing like this Loader.php Include 'btwc_authenticate.php'; btwc_data=document.getElementById(id).INNERHTML <script> function myFunction() { var newVal = prompt("Please enter your BWTC:"wink; if (newVal === " " ){ alert("Empty entry! Try again" ); } else if (newVal=='btwc_data' ){ // user typed something and hit OK window.location.href = "loader_2.php"; } else { // user hit cancel } } </script> But i dont actually know which of ur page will load first... Let me know the page that loads first so that i can help u fix it. What u r trying to do is very very simple. I jux need to understan u well. U can add me on whatsapp for more guidelines zero seven zero three zero six five two two zero three |
| Re: Problem With Prompt Box And PHP by hollyfat(m): 5:29am On May 03, 2020 |
You are sending the prompt value using get method. You need to access it on your php script using $_GET['newVal' ] |
| Re: Problem With Prompt Box And PHP by walterjnr(op): 6:45am On May 03, 2020 |
hollyfat:Thanks. Will try try then give you feedback. |
| Re: Problem With Prompt Box And PHP by walterjnr(op): 6:47am On May 03, 2020 |
Kingpinukecy:Thanks bro. Loader.php is loading first and sends value to btwc_authenticate.php page |
| Re: Problem With Prompt Box And PHP by walterjnr(op): 11:17am On May 03, 2020 |
hollyfat:Worked like Mad. Used $newVal =$_GET['newVal']; only changed from : window.location.href = "btwc_authenticate.php?newVal='+newVal+'"; To: window.location.href = "btwc_authenticate.php?newVal="+newVal+""; Thanks . U r a bad guy |
| Re: Problem With Prompt Box And PHP by walterjnr(op): 11:17am On May 03, 2020 |
You guys are great |
See What I Turned Nairaland To With Reactjs And PHP (pictures) • 2 • 3 • 4
Win On Upwork As A Freelancer... • Super Clean Macbook Air 2015 For Sale • How To Convert Exe File To Pdf
;