0

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 
session_start();

	$charMessage = "";
	$charMessage2 = "";
	$jobsMessage = "";
	$passMessage = "";
	$passMessage2 = "";
	$emailMessage = "";
	$emailMessage2 = "";
	$essayMessage = "";
	$codeMessage = "";
	$CharFont = "allClearFont";
	$jobsFont = "allClearFont";
	$passFont = "allClearFont";
	$emailFont = "allClearFont";
	$essayFont = "allClearFont";
	$codeFont = "allClearFont";
	$charName = strip_tags($_POST['charName']);
	$jobs = strip_tags($_POST['jobs']);
	$pass1 = strip_tags($_POST['pass1']);
	$pass2 = strip_tags($_POST['pass2']);
	$email = strip_tags($_POST['email']);
	$email2 = strip_tags($_POST['email2']);
	$zm = strip_tags($_POST['zm']);
	$cop = strip_tags($_POST['cop']);
	$toa = strip_tags($_POST['toa']);
	$wotg = strip_tags($_POST['wotg']);
	$essay = strip_tags($_POST['essay']);
	$code = strip_tags($_POST['code']);

	if (isset($_POST['submit'])) 
	{

		##################
		# CHECK CHAR NAME
		##################
		if(strlen($charName) < 4 || strlen($charName) > 16 || $charName == "")
		{
			$charFont = "errorFont";
			$charMessage = "Character Name must be between 4 and 16 characters.";
		}
		else if(!ctype_alpha($charName))
		{
			$charMessage2 = "Character name cannot contain any numbers.";
			$charFont = "errorFont";
		}
		##################
		# CHECK JOBS
		##################
		if(strlen($jobs) < 3)
		{
			$jobsFont = "errorFont";
			$jobsMessage = "You have not added your jobs.";
		}
		##################
		# CHECK PASSWORD
		##################
		if(strlen($pass1) < 5 || strlen($pass1) > 15 || strlen($pass2) < 5 || strlen($pass2) > 15 )
		{
			$passMessage = "Password must be between 5 and 15 characters.";
			$passFont = "errorFont";
		}
		else if($pass1 != $pass2)
		{
			$passMessage2 = "Passwords do not match.";
			$passFont = "errorFont";
		}
		##################
		# CHECK EMAIL
		##################
		if(strlen($email) == "")
		{
			$emailMessage = "You have not added your email address.";
			$emailFont = "errorFont";
		}
		else if($email != $email2)
		{
			$emailMessage2 = "Email addresses do not match.";
			$emailFont = "errorFont";
		}
		##################
		# CHECK ESSAY
		##################
		if($essay == "")
		{
			$essayMessage = "You have not filled out \"In your own words\".";
			$essayFont = "errorFont";
		}		
		##################
		# CHECK CAPTCHA
		##################
		if(isset($_POST['code']) && isset($_SESSION['code'])) 
		        if(md5($_POST['code']) != $_SESSION['code']) 
			{
				$codeMessage = "Validation Incorrect.";
				$codeFont = "errorFont";
			}

    }
		##################
		# ALL CLEAR STUFF
		##################
	else
	{
               // DO REDIRECTION HERE  }

?>

<html>
<head>
<link rel="stylesheet" href="../lib/luna.css" type="text/css"/>
<title>Luna Knights::Application for Membership</title>
</head>

<body onload="window.resizeTo(800,600); window.moveTo(100,100);">
<div id="contents">

<strong>Luna Knights Application</strong>
<br/>
Please fill out the form completely:
<br/><br/>

<form method="post" target="_self">
<fieldset id="applyInfoFieldset">
<legend name="legend">Your Information</legend>
<table width="97%" style="border: none;">
<tr>
<td align="left" class="hideIt <?php echo $charFont;?>">Character Name:</td>
<td align="left" class="hideIt"><input class="input" value="<?php echo $charName;?>" type="text" id="charName" name="charName" maxlength="16" cols="35"/></td>
<td class="hideIt"><?php if($charMessage != "") { echo $charMessage; } else if($charMessage2 != "") { echo $charMessage2; }?></td>
<td align="right" class="hideIt <?php echo $jobsFont;?>">List level 75 Jobs:</td>
<td align="right" class="hideIt"><input type="text" class="input" value="<?php echo $jobs;?>" id="jobs" name="jobs" maxlength="100" cols="50"/></td>
<td class="hideIt"><?php if($jobsMessage != "") { echo $jobsMessage; }?></td>
</tr>

<tr>
<td align="left" class="hideIt <?php print $passFont;?>">Password:</td>
<td align="left" class="hideIt"><input class="input" value="<?php echo $pass1;?>" type="password" id="pass1" name="pass1" maxlength="15" cols="35"/></td>
<td class="hideIt"><?php if($passMessage != "") { echo $passMessage; } else if($passMessage2 != "") { echo $passMessage2; }?></td>
<td align="right" class="hideIt <?php print $passFont;?>">Repeat Password:</td>
<td align="right" class="hideIt"><input class="input" value="<?php echo $pass2;?>" type="password" id="pass2" name="pass2" maxlength="15" cols="35"/></td>
</tr>

<tr>
<td align="left" class="hideIt <?php print $emailFont;?>">Email:</td>
<td align="left" class="hideIt"><input class="input" value="<?php echo $email;?>" type="text" id="email" name="email" maxlength="150"/></td>
<td class="hideIt"><?php if($emailMessage != "") { echo $emailMessage; } else if($emailMessage2 != "") { echo $emailMessage2; }?></td>
<td align="right" class="hideIt <?php print $emailFont;?>">Confirm Email:</td>
<td align="right" class="hideIt"><input class="input" value="<?php echo $email2;?>" type="text" id="email2" name="email2" maxlength="150"/></td>
</tr>
</table>
</fieldset>


<fieldset id="applyMissionFieldset">
<legend name="legend">Mission Status</legend>
<table width="90%" style="border: none;">
<tr>
<td align="left" class="hideIt">Zilart:</td>
<td align="left" class="hideIt"><input type="text" class="input" maxlength="5" name="zm" value="<?php echo $zm;?>" style="width: 45px;"/></td>
<td align="right" class="hideIt">CoP</td>
<td align="right" class="hideIt"><input type="text" class="input" maxlength="5" name="cop" value="<?php echo $cop;?>" style="width: 45px;"/></td>
</tr>

<tr>
<td align="left" class="hideIt">Aht Urgan</td>
<td align="left" class="hideIt"><input type="text" class="input" maxlength="5" name="toa" value="<?php echo $toa;?>" style="width: 45px;"/></td>
<td align="right" class="hideIt">WotG</td>
<td align="right" class="hideIt"><input type="text" class="input" maxlength="5" name="wotg" value="<?php echo $wotg;?>" style="width: 45px;"/></td>
</tr>
</table>
</fieldset>

<fieldset id="applyEssayFieldset">
<legend name="legend">In your own Words</legend>
<?php if($essayMessage != "") { echo $essayMessage."<br/>"; }?>
<span class="<?php echo $essayFont;?>">Why should you be a member of Luna Knights?</span>
<br/>
<textarea name="essay" maxlength="500" style="width: 600px; height: 100px;" wrap="hard"><?php if($essay != "") { echo $essay; } ?></textarea>
</fieldset>


<table width="25%" style="border: none;">
<tr>
<td align="left" class="hideIt">Verification Code:</td>
</tr>

<tr>
<td align="left" class="hideIt"><img src="../images/verify.php"></td>
</tr>

<tr>
<td align="left" class="hideIt"><input class="input" type="text" name="code" maxlength="6"/></td>
<td align="right" class="hideIt"><input type="submit" id="submit" name="submit" class="button" value="Submit"/></td>
</tr>

<tr>
<td class="hideIt <?php echo $codeFont;?>" align="left"><?php if($codeMessage != "") { echo $codeMessage; }?></td>
</tr>
</table>
</form>

</div>
</body>
</html>

Edited by sleign: n/a

2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by Devoted Hosting
1

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?

0

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 ^^

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.