943,071 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 729
  • PHP RSS
Nov 15th, 2009
0

script relies on a side effect which existed until php 4.2.3?

Expand Post »
ok laugh at me if you will, call my code sloppy or retarded or not very secure (I'm self-taught and think I do pretty good for where I'm at) but I'm pretty proud of myself for having figured this out.

I've been trying to validate a form for the past almost 15 hours now, in strictly php because javascript is so immense that it seems every last keyword is a word you can find in the english dictionary, and ajax builds off js. So I found a way to validate a form without any data loss on user submission if a field is incorrectly filled out / neglected.

It works so beautifully it makes me wanna cry. It only took 27 variables to do, which I know I could probably put them in arrays, but hey, I've been at this 15 hours straight and I'm not gonna clean it up right now lol. I also know there are ways to validate email addresses far better than checking for an empty string - I will get on that very soon - for now I just wanted the validation part to work correctly in all fields I needed it to check

The only problem I have with this, is I get a warning message which I cannot figure out where it's coming from - since line 0 is the declaration of a php file.

The error message is this:
Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

I am hosted thru godaddy so I don't exactly have access to these files, so I'm trying to figure out what I can do to make this warning disappear.

Basically the way this form is called is a user clicks on a link and then a popup appears which displays terms of registration. The user agrees and clicks on a submit button, which will take them to this form I'm about to put the code down for. I don't get why this error message appears?

If someone can help me out or point me in the right direction as to why. I haven't really taught myself php 5.x yet, I'm still on 4. This is the first time I've seen an error message about 4.x - it's always been earlier versions if I did something funky.

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. session_start();
  3.  
  4. $charMessage = "";
  5. $charMessage2 = "";
  6. $jobsMessage = "";
  7. $passMessage = "";
  8. $passMessage2 = "";
  9. $emailMessage = "";
  10. $emailMessage2 = "";
  11. $essayMessage = "";
  12. $codeMessage = "";
  13. $CharFont = "allClearFont";
  14. $jobsFont = "allClearFont";
  15. $passFont = "allClearFont";
  16. $emailFont = "allClearFont";
  17. $essayFont = "allClearFont";
  18. $codeFont = "allClearFont";
  19. $charName = strip_tags($_POST['charName']);
  20. $jobs = strip_tags($_POST['jobs']);
  21. $pass1 = strip_tags($_POST['pass1']);
  22. $pass2 = strip_tags($_POST['pass2']);
  23. $email = strip_tags($_POST['email']);
  24. $email2 = strip_tags($_POST['email2']);
  25. $zm = strip_tags($_POST['zm']);
  26. $cop = strip_tags($_POST['cop']);
  27. $toa = strip_tags($_POST['toa']);
  28. $wotg = strip_tags($_POST['wotg']);
  29. $essay = strip_tags($_POST['essay']);
  30. $code = strip_tags($_POST['code']);
  31.  
  32. if (isset($_POST['submit']))
  33. {
  34.  
  35. ##################
  36. # CHECK CHAR NAME
  37. ##################
  38. if(strlen($charName) < 4 || strlen($charName) > 16 || $charName == "")
  39. {
  40. $charFont = "errorFont";
  41. $charMessage = "Character Name must be between 4 and 16 characters.";
  42. }
  43. else if(!ctype_alpha($charName))
  44. {
  45. $charMessage2 = "Character name cannot contain any numbers.";
  46. $charFont = "errorFont";
  47. }
  48. ##################
  49. # CHECK JOBS
  50. ##################
  51. if(strlen($jobs) < 3)
  52. {
  53. $jobsFont = "errorFont";
  54. $jobsMessage = "You have not added your jobs.";
  55. }
  56. ##################
  57. # CHECK PASSWORD
  58. ##################
  59. if(strlen($pass1) < 5 || strlen($pass1) > 15 || strlen($pass2) < 5 || strlen($pass2) > 15 )
  60. {
  61. $passMessage = "Password must be between 5 and 15 characters.";
  62. $passFont = "errorFont";
  63. }
  64. else if($pass1 != $pass2)
  65. {
  66. $passMessage2 = "Passwords do not match.";
  67. $passFont = "errorFont";
  68. }
  69. ##################
  70. # CHECK EMAIL
  71. ##################
  72. if(strlen($email) == "")
  73. {
  74. $emailMessage = "You have not added your email address.";
  75. $emailFont = "errorFont";
  76. }
  77. else if($email != $email2)
  78. {
  79. $emailMessage2 = "Email addresses do not match.";
  80. $emailFont = "errorFont";
  81. }
  82. ##################
  83. # CHECK ESSAY
  84. ##################
  85. if($essay == "")
  86. {
  87. $essayMessage = "You have not filled out \"In your own words\".";
  88. $essayFont = "errorFont";
  89. }
  90. ##################
  91. # CHECK CAPTCHA
  92. ##################
  93. if(isset($_POST['code']) && isset($_SESSION['code']))
  94. if(md5($_POST['code']) != $_SESSION['code'])
  95. {
  96. $codeMessage = "Validation Incorrect.";
  97. $codeFont = "errorFont";
  98. }
  99.  
  100. }
  101. ##################
  102. # ALL CLEAR STUFF
  103. ##################
  104. else
  105. {
  106. // DO REDIRECTION HERE }
  107.  
  108. ?>
  109.  
  110. <html>
  111. <head>
  112. <link rel="stylesheet" href="../lib/luna.css" type="text/css"/>
  113. <title>Luna Knights::Application for Membership</title>
  114. </head>
  115.  
  116. <body onload="window.resizeTo(800,600); window.moveTo(100,100);">
  117. <div id="contents">
  118.  
  119. <strong>Luna Knights Application</strong>
  120. <br/>
  121. Please fill out the form completely:
  122. <br/><br/>
  123.  
  124. <form method="post" target="_self">
  125. <fieldset id="applyInfoFieldset">
  126. <legend name="legend">Your Information</legend>
  127. <table width="97%" style="border: none;">
  128. <tr>
  129. <td align="left" class="hideIt <?php echo $charFont;?>">Character Name:</td>
  130. <td align="left" class="hideIt"><input class="input" value="<?php echo $charName;?>" type="text" id="charName" name="charName" maxlength="16" cols="35"/></td>
  131. <td class="hideIt"><?php if($charMessage != "") { echo $charMessage; } else if($charMessage2 != "") { echo $charMessage2; }?></td>
  132. <td align="right" class="hideIt <?php echo $jobsFont;?>">List level 75 Jobs:</td>
  133. <td align="right" class="hideIt"><input type="text" class="input" value="<?php echo $jobs;?>" id="jobs" name="jobs" maxlength="100" cols="50"/></td>
  134. <td class="hideIt"><?php if($jobsMessage != "") { echo $jobsMessage; }?></td>
  135. </tr>
  136.  
  137. <tr>
  138. <td align="left" class="hideIt <?php print $passFont;?>">Password:</td>
  139. <td align="left" class="hideIt"><input class="input" value="<?php echo $pass1;?>" type="password" id="pass1" name="pass1" maxlength="15" cols="35"/></td>
  140. <td class="hideIt"><?php if($passMessage != "") { echo $passMessage; } else if($passMessage2 != "") { echo $passMessage2; }?></td>
  141. <td align="right" class="hideIt <?php print $passFont;?>">Repeat Password:</td>
  142. <td align="right" class="hideIt"><input class="input" value="<?php echo $pass2;?>" type="password" id="pass2" name="pass2" maxlength="15" cols="35"/></td>
  143. </tr>
  144.  
  145. <tr>
  146. <td align="left" class="hideIt <?php print $emailFont;?>">Email:</td>
  147. <td align="left" class="hideIt"><input class="input" value="<?php echo $email;?>" type="text" id="email" name="email" maxlength="150"/></td>
  148. <td class="hideIt"><?php if($emailMessage != "") { echo $emailMessage; } else if($emailMessage2 != "") { echo $emailMessage2; }?></td>
  149. <td align="right" class="hideIt <?php print $emailFont;?>">Confirm Email:</td>
  150. <td align="right" class="hideIt"><input class="input" value="<?php echo $email2;?>" type="text" id="email2" name="email2" maxlength="150"/></td>
  151. </tr>
  152. </table>
  153. </fieldset>
  154.  
  155.  
  156. <fieldset id="applyMissionFieldset">
  157. <legend name="legend">Mission Status</legend>
  158. <table width="90%" style="border: none;">
  159. <tr>
  160. <td align="left" class="hideIt">Zilart:</td>
  161. <td align="left" class="hideIt"><input type="text" class="input" maxlength="5" name="zm" value="<?php echo $zm;?>" style="width: 45px;"/></td>
  162. <td align="right" class="hideIt">CoP</td>
  163. <td align="right" class="hideIt"><input type="text" class="input" maxlength="5" name="cop" value="<?php echo $cop;?>" style="width: 45px;"/></td>
  164. </tr>
  165.  
  166. <tr>
  167. <td align="left" class="hideIt">Aht Urgan</td>
  168. <td align="left" class="hideIt"><input type="text" class="input" maxlength="5" name="toa" value="<?php echo $toa;?>" style="width: 45px;"/></td>
  169. <td align="right" class="hideIt">WotG</td>
  170. <td align="right" class="hideIt"><input type="text" class="input" maxlength="5" name="wotg" value="<?php echo $wotg;?>" style="width: 45px;"/></td>
  171. </tr>
  172. </table>
  173. </fieldset>
  174.  
  175. <fieldset id="applyEssayFieldset">
  176. <legend name="legend">In your own Words</legend>
  177. <?php if($essayMessage != "") { echo $essayMessage."<br/>"; }?>
  178. <span class="<?php echo $essayFont;?>">Why should you be a member of Luna Knights?</span>
  179. <br/>
  180. <textarea name="essay" maxlength="500" style="width: 600px; height: 100px;" wrap="hard"><?php if($essay != "") { echo $essay; } ?></textarea>
  181. </fieldset>
  182.  
  183.  
  184. <table width="25%" style="border: none;">
  185. <tr>
  186. <td align="left" class="hideIt">Verification Code:</td>
  187. </tr>
  188.  
  189. <tr>
  190. <td align="left" class="hideIt"><img src="../images/verify.php"></td>
  191. </tr>
  192.  
  193. <tr>
  194. <td align="left" class="hideIt"><input class="input" type="text" name="code" maxlength="6"/></td>
  195. <td align="right" class="hideIt"><input type="submit" id="submit" name="submit" class="button" value="Submit"/></td>
  196. </tr>
  197.  
  198. <tr>
  199. <td class="hideIt <?php echo $codeFont;?>" align="left"><?php if($codeMessage != "") { echo $codeMessage; }?></td>
  200. </tr>
  201. </table>
  202. </form>
  203.  
  204. </div>
  205. </body>
  206. </html>
Last edited by sleign; Nov 15th, 2009 at 5:58 am.
Similar Threads
Reputation Points: 11
Solved Threads: 3
Light Poster
sleign is offline Offline
36 posts
since Sep 2008
Nov 15th, 2009
1
Re: script relies on a side effect which existed until php 4.2.3?
GoDaddy's hosting can be pretty weird. Can you create custom php.ini or .htaccess files? If so try adding either into your public (web-accessible) folder:

A file named "php.ini" containing:

session.bug_compat_42 = 1
session.bug_compat_warn = 0

OR

A file name ".htaccess" containing:

php_flag session.bug_compat_42 1
php_flag session.bug_compat_warn 0

See if that helps?
Reputation Points: 12
Solved Threads: 6
Light Poster
Devoted Hosting is offline Offline
29 posts
since Nov 2009
Nov 15th, 2009
0
Re: script relies on a side effect which existed until php 4.2.3?
u are god - that worked perfectly thank you

I tried to upload a php.ini file into root and the warning went away.
good call ^^
Reputation Points: 11
Solved Threads: 3
Light Poster
sleign is offline Offline
36 posts
since Sep 2008
Nov 15th, 2009
0
Re: script relies on a side effect which existed until php 4.2.3?
You're welcome
Reputation Points: 12
Solved Threads: 6
Light Poster
Devoted Hosting is offline Offline
29 posts
since Nov 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: single account for two sites
Next Thread in PHP Forum Timeline: please help: moving a new sidebar from right to left





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC