Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

preg_match errors


jaggedlancer's Avatar
The Localhost Hacker
20 0

Hey, i got this code

require_once('core.php');
require_once('top.php');
require_once('left.php');
?>

<td>
<?php
if(!isset($username_cu)){
print "You Must Be Logged In To Edit A Profile";
}else{
//set the vars
$email = $_POST['email'];
$avatar = $_POST['avatar'];
$sig = htmlentities($_POST['sig']);
$dob = $_POST['dob'];
$aim = $_POST['aim'];
$msn = $_POST['msn'];
$skype = $_POST['skype'];


//checks if the user has inputted anything into the fields
if($_POST){
	
	print "<table><tr><Td>";	


	//email
	if(!preg_match("/\>\<\(\)-0-9A-Z_\$\+\^\.\/\\/", $email) | !preg_match("/@/")){
		print "Email Is Invalid And/or COntains Invalid Characters";
	}else{
	//Edit The Email Section
		$email_edit = "UPDATE `users` SET `email` = '$email' WHERE `name` = '$username' LIMIT 1";
		$email_update = mysql_query($email_edit);
	}
	
	//avatar
	if(!preg_match("/[-0-9A-Z_@\$\+\.\\/", $avatar)){
		print "Avatar Location Contains Invalid Characters";
	}else{
	//Edit the Avatar Section
		$avatar_edit = "UPDATE `users` SET `avvie` = '$avatar' WHERE `name` = $username LIMIT 1";
		$avatar_update = mysql_query($avatar_edit);
	}
	
	
	//skype
	if(!preg_match("/\<\>\(\)\'\^-0-9A-Z_\$\+\^\/\\/", $skype)){
		print "Skype Name Contains Invalid Characters";
	}else{
	//Edit The Skype Section
		$skype_edit = "UPDATE `users` SET `skype` = '$skype' WHERE `name` = $username LIMIT 1";
		$skype_update = mysql_query($skype_edit);
	}
	
	
	
	//password
	if($pass!= $pass_2){
		print "Both Passwords Must Be The Same";
	}else{
		$password_edit = "UPDATE `users` SET `password` = '$password' WHERE `name` = $username LIMIT 1";
		$password_update = mysql_query($password_edit);
	}
	
	//aim
	if(!preg_match("/-0-9A-Z_@\$\^\+\/\\/", $aim)){
		print "AIM address Contains Invalid Characters";
	}else{
		$aim_edit = "UPDATE `users` SET `aim` = '$aim' WHERE `name` = $username LIMIT 1";
		$aim_update = mysql_query($aim_edit);
	}
	
	
	//msn
	if(!preg_match("/-0-9A-Z_@\$\+/.\^\/\\/", $msn)){
		print "<br>Msn Address Contains Invalid Characters";
	}else{
		$msn_edit = "UPDATE `users` SET `msn` = '$msn' WHERE `name` = $username LIMIT 1";
		$msn_update = mysql_query($msn_edit);
	}
	
/*	//dob
	if(!preg_match("/0-9/", $dob)){
		print "<br>Date Of Birth Contains Invalid Characters";
	}else{
		$dob_edit = "UPDATE `users` SET `dob` = '$dob' WHERE `name` = $username LIMIT 1";
		$dob_update = mysql_query($dob_edit);
	}
*/
	print "<br>All changes Saved Sucsessfully!<br>";

	print "</td></tr></table>";

//if the user doesnt input anything , then display the form
}
print "<form method=post>";
print "<table>";

print "<tr>";
print "<td>Password</td>";
print "<td><input class=tb type='password' name='pass' value=''></td>";
print "</tr>";


print "<tr>";
print "<td>Confirm Password</td>";
print "<td><input class=tb type='password' name='pass_2' value=''></td>";
print "</tr>";

	
print "<tr>";
print "<td>Msn</td>";
print "<td><input class=tb type='text' name='msn' value='" . $current['msn'] . "'></td>";
print "</tr>";
		
print "<tr>";
print "<td>AIM</td>";
print "<td><input class=tb type='text' name='aim' value='" . $current['aim'] . "'></td>";
print "</tr>";


print "<tr>";
print "<td>Skype</td>";
print "<td><input class=tb type='text' name='skype' value='" . $current['skype'] . "'></td>";
print "</tr>";
	
	
print "<tr>";
print "<td>Avatar</td>";
print "<td><input class=tb type='text' name='avatar' value='" . $current['avvie'] . "'></td>";
print "</tr>";
	
	
print "<tr>";
print "<td>Email</td>";
print "<td><input class=tb type='text' name='email' value='" . $current['email'] . "'></td>";
print "</tr>";


print "<tr>";
print "<td>Signiture</td>";
print "<td> <textarea cols=70 rows=8 class=ta name='sig'>" . $current['sig'] . "</textarea></td></tr>";
print "<Tr><td colspan=2 align=center><input type=submit name=submit value=Submit! class=button></td>";

print "</tr></table>";
}

print "</td>";
require_once('right.php');
require_once('bottom.php');
?>

ok but i keep getting preg_match errors. Any help? Thanks :happy:


ghost's Avatar
0 0

Replace all the calls to preg_match() with ereg(). Ereg takes the same parameters as you are using for preg_match at the moment.

See if that fixes it.


ghost's Avatar
0 0

I'm not the best person for debugging regex, but this may solve a part of the problem:

if(!preg_match("**/[-0-**9A-Z_@\$\+\.\\/", $avatar)){

Try removing the - before the 0.


ghost's Avatar
0 0

 //password
if($pass != $pass_2){
print "<br>Both Passwords Must Be The Same";
}else{
$password_edit = "UPDATE `users` SET `password` = '$new_pwd' WHERE `name` = '$username_cu' LIMIT 1";
$password_update = mysql_query($password_edit) or

mysql_error();
}

Added the single quotes around $username_cu, and where is $new_pwd being defined?


ghost's Avatar
0 0

Why so many UPDATE queries?