Jump to content

jParnell

New Members
  • Posts

    9
  • Joined

  • Last visited

jParnell's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've been banging my head against the wall for hours on this, and I finally figured it out.... I changed if(isset($_REQUEST['referrer'])){ header("Refresh:0, url=/"); } to if(isset($_REQUEST['referrer'])){ header("Refresh:0; url=/"); } Low and behold, it works. changing a single character un-breaks it with IE. As much as I abhor IE, at least it makes you make sure your code is correct
  2. I thought I got the $no_referrer variable in there, apparently not. That variable is set to 0 by default. Content on the site is called dynamically, dependent on the $referral variable. The $referral variable is defining the affiliate link of the site. I'll admit to being no expert in PHP, but as I stated above, the $referrer is the affiliate link. The link is generated from a mysql query dependent on the affiliate's id, the primary row in the database, which is 'referrer'. Each affiliate has a link in their profile. <?php session_start(); include('dbconnect.php'); $username = $_SESSION['username']; $referralid = mysql_query("SELECT ref_id FROM my_table WHERE username = $username"); echo "Your affiliate link is <span class='bold'>http://website.com/?referral=?" . $referralid . "</span><br />"; ?> As I said, I'm no PHP expert, so this is the logical way I saw to creating dynamic affiliate links. If you have a suggestion for an alternative method, I'm open to it. In every single test I've done in my sandbox environment, it has worked flawlessly in every browser, until I decided to add the header() portion, in which case only IE is flubbing it up. The problem is on the execution, IE is maintaining the ?referrer=abc123 inside the url. it's adding to my header(); function, therefore when always passes the if() check.
  3. ok, so I did an echo $_REQUEST['referrer']; in my header. In Chrome, Firefox, Opera, and Safari, I get the following error message: Notice: Undefined index: referrer in C:\xampp\htdocs\index.php on line 36 Which is completely to be expected after the refresh. However, on IE (every version) it is echoing the contents of $_REQUEST['referrer'] as if "?referrer=abc123" were still appended to the URL. If I had to harbor a guess as to why IE is jacking it up, I would say its the lines: if(isset($_REQUEST['referrer'])){ $referrer = $_REQUEST['referrer']; } I think IE is thinking that $referrer should literally be $_REQUEST['referrer'] instead of the value of the request global variable.... Anybody have any idea how to fix this?
  4. OK, I'll keep this short n sweet. Goal: If a specific variable is declared in the URL, assign it to a session and refresh the page without the variable. Here's my code: if(isset($_SESSION['referrer'])){ $referrer = $_SESSION['referrer']; }else{ if(isset($_REQUEST['referrer'])){ $referrer = $_REQUEST['referrer']; }else{ $referrer = $no_referrer; } } $_SESSION['referrer'] = $referrer; if(isset($_REQUEST['referrer'])){ header("Refresh:0, url=/"); } Expected result: If the url http://testsite.com?referrer=abc123 is entered, check for existing session. If it doesn't exist, create one from $_REQUEST['referrer']. Then, check if $_REQUEST['referrer'] exists. If it does, immediately go to the root of the domain (this is located at the root of the domain) so that the url displayed is http://testsite.com instead of the ugly referrer showing. Actual Result: Works great on Chrome, Firefox, Safari, Opera, and Android 4.2.2's web browser, however in IE 8 through IE 11, that code presents an infinite header(); loop. It's executing the header("Refresh:0, url=/"); regardless of whether $_REQUEST['referrer'] is set or not
  5. Try replacing function session_is_registered() with: if(isset($_SESSION[''])){ } // replace whatever is in the (*) on the original inside the ['*'] on the new as well, replace function session_register() with this line: $_SESSION['*'] = $_REQUEST['*'} // Replace the asterisks with what was in the parentheses in the original
  6. rofl I noticed that in my source after I posted this it wasn't popping any error messages, or I would have noticed it sooner. I had copied the script from another site I had where it had $password and $vpassword, and I guess I removed the v or something... i dont know, it was 4 am this morning when I wrote this, 22 hour days tend to lead to fuzzy code
  7. Brilliant! I changed the original lines of: <?php $referredby = $_REQUEST['referredby']; $email = $_REQUEST['email']; $name = $_REQUEST['name']; $password = $_REQUEST['password']; $earned = $_REQUEST['earned']; $image = $_REQUEST['image']; if($email && $name && $password && $password && $earned) { mysql_connect("dbserver", "username", "password") or die To: <?php if(isset($_REQUEST['email']) && isset($_REQUEST['name']) && isset($_REQUEST['password']) && isset($_REQUEST['earned'])) { $referredby = $_REQUEST['referredby']; $email = $_REQUEST['email']; $name = $_REQUEST['name']; $password = $_REQUEST['password']; $earned = $_REQUEST['earned']; $image = $_REQUEST['image']; mysql_connect("dbserver", "username", "password") or die( Now works brilliantly! I just wonder why it worked last night and didn't today? I swear, I changed absolutely NOTHING!
  8. Just found something interesting....... when filling out the form, on the input marked EARNED, if I set it to 0, it will not run. If I set it to 1, it runs successfully. Last night I was setting it to 0 all night long for about 20 different dummy test users. Now, nothing. Here's how my table is set up:
  9. Bear with me, I'm new to PHP and MySQL. Ok, so strange thing. Last night, I'm coding it up, everything's working great. Go to bed, wake up, now my form isn't working. Literally 9 hours before, it was. Nothing changed, suddenly isn't working. I have 2 files, form.php and insert.php. form.php: <html> <head> <title>YAY!</title> </head> <body> <h2>Register Form</h2> <form method="get" action="insert.php"> <table border="0" width="60%"> <tr> <td width="10%">Referred By: </td><td><input type="text" name="referredby" /></td> </tr> <tr> <td width="10%">Email: </td><td><input type="text" name="email" /></td> </tr> <tr> <td width="10%">Name: </td><td><input type="text" name="name" /></td> </tr> <tr> <td width="10%">Password: </td><td><input type="text" name="password" /></td> </tr> <tr> <td width="10%">Earned: </td><td><input type="text" name="earned" /></td> </tr> <tr> <td width="10%">Image: </td><td><input type="text" name="image" /></td> </tr> </table> <p> <input type="submit" value="Register" /> <input type="reset" value="reset" /> </form> </body> </html> insert.php: <?php $referredby = $_REQUEST['referredby']; $email = $_REQUEST['email']; $name = $_REQUEST['name']; $password = $_REQUEST['password']; $earned = $_REQUEST['earned']; $image = $_REQUEST['image']; if($email && $name && $password && $password && $earned) { mysql_connect("dbserver", "username", "password") or die("Problem connecting to the database server. Please contact administrator at <link to contact form here> with the following error message: " . mysql_errno() . ": " . mysql_error() . "<br />" ); mysql_select_db("database"); mysql_query("INSERT INTO desiredtable(referredby,email,name,password,earned,image) VALUES('$referredby','$email','$name','$password','$earned','$image')"); $registered = mysql_affected_rows(); echo "$name was successfully registered! $registered row(s) added to the table."; mysql_close(); }else{ echo "You have to complete the form<br />"; echo "Email: " . $email . "<br />" . "Name: " . $name . "<br />" . "password: " . $password . "<br />" . "Earned: " . $earned . "<br />"; } echo mysql_errno() . ": " . mysql_error() . "<br />"; echo "<a href=\"form.php\">Return to the previous page</a>" ?> Now, here's the kicker. When I fill out the form and click register, I have my else { } statement echo the $_REQUEST[ ] variables (added that for troubleshooting), and it's displaying the contents correctly. I even changed my form from method="post" to method="get" to verify in the address bar. Apparently, everything before and after the initial IF statement conditions are working correctly. It's the conditions that are not, which doesn't make sense, because as I said, I was using it last night in order to add entries into my table. It's probably something really simple stupid, and I'm hoping you can help me out with it :/ FYI, this is set up under a XAMPP installation on my PC
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.