duckygray Posted September 7, 2019 Share Posted September 7, 2019 Okay I have index.php in which i used <?php echo $_GET['name']; ?> and its working fine all over the page except a wizard form that loads on a button click. <?php echo $_GET['name']; ?> is working on entire page text (wherever i have used this) except a wizard form which loads on a button click. All the files of that wizard form are located in my website folder (e.g. wizard.php, wizard.js & wizard.css). here's how wizard.php code starts: <div class="wizard-container"> <div class="card wizard-card" data-color="green" id="wizardProfile"> <form action=""> <div class="wizard-header"> <h3 class="wizard-title"> GENERATE A FRESH <?php echo $_GET['name']; ?> CODE </h3> <h5 style="margin-left: 10px; margin-right: 10px;">Our interactive generator will guide your through the process</h5> </div> i want that <?php echo $_GET['name']; ?> should also work in wizard form but it shows the following error: C:\xampp\htdocs\NameGenerator\content\hbox\html\wizard.php on line 7 Sorry for my bad explanation i don't know much about php so i explained it like this Please help... Quote Link to comment Share on other sites More sharing options...
Barand Posted September 7, 2019 Share Posted September 7, 2019 How are you passing the "name" value to that page? Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted September 8, 2019 Share Posted September 8, 2019 (edited) This usually happens when you do AJAX Calls I am sure when you click on button there is an ajax call to the wizard.php page. The quick solution will be save name attribute to the session from index.php page $_SESSION['name'] = $_GET['name']; when you read name from session on wizard.php page unset the variable from session unset($_SESSION['name']); Edited September 8, 2019 by inversesoft123 more information added Quote Link to comment Share on other sites More sharing options...
maxxd Posted September 8, 2019 Share Posted September 8, 2019 On 9/7/2019 at 12:51 AM, duckygray said: C😕xampp\htdocs\NameGenerator\content\hbox\html\wizard.php on line 7 That's not the error, that's the file and line on which the error happened - show us the entire message, please. Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted September 8, 2019 Share Posted September 8, 2019 On 9/6/2019 at 9:51 PM, duckygray said: i don't know much about php so i explained it like this There is some things you need to understand first. Your PHP server does not magically know $_GET['name'] . It doesn't even save it. Every time your browser accessed the page, it is actually given this data to the server. $_POST is similar. Go back to your browser, and open the console (F12 for most browsers) and look for a network tab and look what your browser is sending and receiving from the server. For chrome, sending is Form Data at the bottom of the Headers tab, and receiving is the Response tab. Now, look at the content sent and retrieved on your wizard request, and you will see that your browser is not sending a value for name. Therefore, it has no idea what it is. $_SESSION['name'] is storage. Every time your browser accesses the server, it sends a secret cookie which points to the storage. So you "could" in your normal page where $_GET['name'] is being sent copy this value to a session, and then latter in your wizard script retrieve it, but this is most likely not the intended way to do so. Just don't try to save the session in your wizard script because obviously it doesn't have the $_GET['name']. Quote Link to comment 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.