Error |
Error |
tudsy |
Aug 19 2017, 12:35 AM
Post
#1
|
Advanced Member Group: Members Posts: 246 Joined: 30-September 14 Member No.: 21,611 |
Hi
With this query string, I get the error: [19-Aug-2017 05:13:26 UTC] PHP Parse error: syntax error, unexpected '<' in /home/ecovibdc/public_html/ECOVIB2D/MYART/processmidpage.php on line 135 [19-Aug-2017 05:17:15 UTC] PHP Notice: Undefined index: username in /home/ecovibdc/public_html/ECOVIB2D/MYART/ecovib2d1.php on line 187 [19-Aug-2017 05:17:15 UTC] PHP Notice: Undefined index: email in /home/ecovibdc/public_html/ECOVIB2D/MYART/ecovib2d1.php on line 187 When I load ecovib2d1.php, load the graphic and hover over the buy button, I get a 'NaNNaN.........' type of output on the status bar. I do not know what is happening? I think I have defined username and email correctly in the query string? document.getElementById('form').action="http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?username=" + <?php echo $_GET['username'];?> + "&email=" + <?php echo $_GET['email'];?> + "&Person=" + personname + "&Price=" + Priceofart + "&Graphic=" + picname.replace('w.bmp','.bmp'); Thanks. Attached File(s) processmidpage.php ( 3.82k ) Number of downloads: 506 ecovib2d1.php ( 10.02k ) Number of downloads: 465 |
CharlesEF |
Aug 23 2017, 10:36 AM
Post
#2
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
I don't use $_GET very often. I didn't know $_GET would unencode query string values.
You seem to have missed the point of my suggestion. Seems you did remove line 187 but you replaced it with this: CODE function dec(){ Using PHP here is wrong. PHP is only active when the page is loading. When the page loads there is no query string values for 'username' and 'email'. And, you can't use $_GET to retrieve values that haven't been entered yet. Forget about building the query string yourself. PHP will do that for you when the form is submitted.var url = 'http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?Person=personname&Price=priceofart&Graphic=picname&username='; var url1 = <?php echo $_GET['username'] ?>; alert(url1); var url2 = '&email=' + <?php echo $_GET['email'] ?>; document.getElementById('form').action = url + url1.replace('+','%20') + url2; This is your current form: CODE <form id='form' action='processmidpage.php' onsubmit='dec();' method="GET"/> Any Javascript that affects 'Person', 'Price' or 'Graphic' values will have to be changed to use these inputs. Remove the function dec(), you don't need it. Be sure to remove the 'onsubmit' event from the form. After you make these changes and load the page again, all you need to do is fill in the username and email then click the submit button.<input type='hidden' id='person' name='Person'/> <input type='hidden' id='Cost' name='Price' /> <input type='hidden' id='pic' name='Graphic'/> <p align='center' id='freename'>Enter Full Name:</p> <p align='center'><input id='Nameofperson' maxlength='50' name='username' size='50' type='text' /></p> <p align='center' id='freeaddress'>Enter Email-Address:</p> <p align='center'><input id='e-address' maxlength='50' name='email' size='50' type='text' /></p> <input type='submit' id="Buy" value='Buy Now'/> </form> When 'processmidpage.php' loads it will have a query string like this: CODE http://103.226.223.161/~ecovibdc/ECOVIB2D/MYART/processmidpage.php?Person=value&Price=value&Graphic=value&username=value&email=value PHP will build the query string for you, based on the fields in between the <form>...</form> tags.This post has been edited by CharlesEF: Aug 23 2017, 10:42 AM |
Lo-Fi Version | Time is now: 19th April 2024 - 02:04 PM |