cosmoshell Posted March 28, 2008 Share Posted March 28, 2008 <?php include ("config.php"); error_reporting(E_ALL ^ E_NOTICE); session_start(); $msg = Array(); $error = Array(); function addUser(){ if (empty($_POST)) return false; global $config, $msg, $error; if (empty($_POST['login'])) $error[] = 'Error, You forgot to enter a account name!'; if (empty($_POST['password'][0]) || empty($_POST['password'][1])) $error[] = 'Error, You forgot to enter a password!'; if ($_POST['password'][0] !== $_POST['password'][1]) $error[] = 'Password does not match!'; if (empty($_POST['email'])) $error[] = 'Please fill in a valid email adress!'; if (empty($_POST['code'])) $error[] = 'Error, You forgot to enter the code!'; if (!empty($error)) return false; $db = @mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']); if (!$db) return $error[] = 'Database: '.mysql_error(); if (!@mysql_select_db($config['mysql_dbname'], $db)) return $error[] = 'Database: '.mysql_error(); $query = "SELECT `acct` FROM `accounts` WHERE `login` = '".mysql_real_escape_string($_POST['login'])."'"; $res = mysql_query($query, $db); if (!$res) return $error[] = 'Database: '.mysql_error(); if (mysql_num_rows($res) > 0) return $error[] = 'Username already in use.'; $query = "INSERT INTO `accounts` (`login`,`password`,`lastip`, `email`, `flags`) VALUES ('".mysql_real_escape_string($_POST['login'])."', '".mysql_real_escape_string($_POST['password'][0])."', '".$_SERVER['REMOTE_ADDR']."', '".mysql_real_escape_string($_POST['email'])."', '8')"; $res = mysql_query($query, $db); if (!$res) return $error[] = 'Database: '.mysql_error(); $msg[] = 'The Account <span style="color:#00FF00"><strong>'.htmlentities($_POST['login']).'</strong></span> has been created!'; mysql_close($db); return true; } { addUser(); } include ("template.php"); session_start(); $ts = time(); ?> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Account Creation Page</title> <meta http-equiv="Pragma" content="no-cache"/> <meta http-equiv="Cache-Control" content="no-cache"/> <style type="text/css" media="screen">@import url(server_stats.css);</style> <!--[if lt IE 7.]> <script defer type="text/javascript" src="pngfix.js"></script> <![endif]--> </head> <body> <script language="JavaScript"><!-- ts = <?= $ts ?>; --></script> <center> <div class="logo"></div> <div style="width:300px"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <table width="100%" border="0" cellspacing="1" cellpadding="2"> <tr class="head"><th colspan="2">Account Creation</th></tr> <tr> <th>Username: </th><td align="center"><input class="button" type="text" name="login" size="30" maxlength="16"/></td> </tr> <tr> <th>Password: </th><td align="center"><input class="button" type="password" name="password[]" size="30" maxlength="16"/></td> </tr> <tr> <th>Retype Password: </th><td align="center"><input class="button" type="password" name="password[]" size="30" maxlength="16"/></td> </tr> <tr> <th>E-mail: </th><td align="center"><input class="button" type="text" name="email" size="30" maxlength="30"/></td> </tr> <tr> <th>Enter the code shown <a href="no_matter" onclick="document.getElementById('__code__').src = 'code.php?id=' + ++ts; return false">New Code</a></p></th><td align="center"><img id="__code__" src="code.php?id=<?= $ts ?></td> </tr> <tr> <th>Code</th><td align="center"><input class="button" type="text" name="code" size="30" maxlength="6"/></td> </tr> </table> <input type="button" class="button" value="Back" onClick="history.go(-1)" /> <input type="submit" value="Create" class="button"/> </form> <?php if (!empty($error)){ echo '<table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td class="error" align="center">'; foreach($error as $text) echo $text.'</br>'; echo '</td></tr></table>'; }; if (!empty($msg)){ echo '<table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td align="center">'; foreach($msg as $text) echo $text.'</br>'; echo '</td></tr></table>'; exit(); }; ?> </div> </center> </body> </html> i need to get this to work in here and i dont know jack about php <form method="post"></form><? if (isset($_POST['code'])) echo (md5(strtoupper($_POST['code'])) == $_SESSION['__img_code__']) ? "Valid!" : "Invalid!"; ?></a> Link to comment https://forums.phpfreaks.com/topic/98274-need-help-with-adding-image-validator-to-a-signup-fourm/ Share on other sites More sharing options...
benjaminbeazy Posted March 28, 2008 Share Posted March 28, 2008 just modified, try it now... <?php include ("config.php"); error_reporting(E_ALL ^ E_NOTICE); session_start(); $msg = Array(); $error = Array(); function addUser(){ if (empty($_POST)) return false; global $config, $msg, $error; if(md5(strtoupper($_POST['code'])) !== $_SESSION['__img_code__']) $error[] 'Invalid Code!'; if (empty($_POST['login'])) $error[] = 'Error, You forgot to enter a account name!'; if (empty($_POST['password'][0]) || empty($_POST['password'][1])) $error[] = 'Error, You forgot to enter a password!'; if ($_POST['password'][0] !== $_POST['password'][1]) $error[] = 'Password does not match!'; if (empty($_POST['email'])) $error[] = 'Please fill in a valid email adress!'; if (empty($_POST['code'])) $error[] = 'Error, You forgot to enter the code!'; if (!empty($error)) return false; $db = @mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']); if (!$db) return $error[] = 'Database: '.mysql_error(); if (!@mysql_select_db($config['mysql_dbname'], $db)) return $error[] = 'Database: '.mysql_error(); $query = "SELECT `acct` FROM `accounts` WHERE `login` = '".mysql_real_escape_string($_POST['login'])."'"; $res = mysql_query($query, $db); if (!$res) return $error[] = 'Database: '.mysql_error(); if (mysql_num_rows($res) > 0) return $error[] = 'Username already in use.'; $query = "INSERT INTO `accounts` (`login`,`password`,`lastip`, `email`, `flags`) VALUES ('".mysql_real_escape_string($_POST['login'])."', '".mysql_real_escape_string($_POST['password'][0])."', '".$_SERVER['REMOTE_ADDR']."', '".mysql_real_escape_string($_POST['email'])."', '8')"; $res = mysql_query($query, $db); if (!$res) return $error[] = 'Database: '.mysql_error(); $msg[] = 'The Account <span style="color:#00FF00"><strong>'.htmlentities($_POST['login']).'</strong></span> has been created!'; mysql_close($db); return true; } { addUser(); } include ("template.php"); session_start(); $ts = time(); ?> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Account Creation Page</title> <meta http-equiv="Pragma" content="no-cache"/> <meta http-equiv="Cache-Control" content="no-cache"/> <style type="text/css" media="screen">@import url(server_stats.css);</style> <!--[if lt IE 7.]> <script defer type="text/javascript" src="pngfix.js"></script> <![endif]--> </head> <body> <script language="JavaScript"><!-- ts = <?= $ts ?>; --></script> <center> <div class="logo"></div> <div style="width:300px"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <table width="100%" border="0" cellspacing="1" cellpadding="2"> <tr class="head"><th colspan="2">Account Creation</th></tr> <tr> <th>Username: </th><td align="center"><input class="button" type="text" name="login" size="30" maxlength="16"/></td> </tr> <tr> <th>Password: </th><td align="center"><input class="button" type="password" name="password[]" size="30" maxlength="16"/></td> </tr> <tr> <th>Retype Password: </th><td align="center"><input class="button" type="password" name="password[]" size="30" maxlength="16"/></td> </tr> <tr> <th>E-mail: </th><td align="center"><input class="button" type="text" name="email" size="30" maxlength="30"/></td> </tr> <tr> <th>Enter the code shown <a href="no_matter" onclick="document.getElementById('__code__').src = 'code.php?id=' + ++ts; return false">New Code</a></p></th><td align="center"><img id="__code__" src="code.php?id=<?= $ts ?></td> </tr> <tr> <th>Code</th><td align="center"><input class="button" type="text" name="code" size="30" maxlength="6"/></td> </tr> </table> <input type="button" class="button" value="Back" onClick="history.go(-1)" /> <input type="submit" value="Create" class="button"/> </form> <?php if (!empty($error)){ echo '<table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td class="error" align="center">'; foreach($error as $text) echo $text.'</br>'; echo '</td></tr></table>'; }; if (!empty($msg)){ echo '<table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td align="center">'; foreach($msg as $text) echo $text.'</br>'; echo '</td></tr></table>'; exit(); }; ?> </div> </center> </body> </html> Link to comment https://forums.phpfreaks.com/topic/98274-need-help-with-adding-image-validator-to-a-signup-fourm/#findComment-502858 Share on other sites More sharing options...
cosmoshell Posted March 28, 2008 Author Share Posted March 28, 2008 doesent work Fatal error: Cannot use [] for reading in C:\Server\htdocs\imgval\reg.php on line 13 Link to comment https://forums.phpfreaks.com/topic/98274-need-help-with-adding-image-validator-to-a-signup-fourm/#findComment-502867 Share on other sites More sharing options...
benjaminbeazy Posted March 28, 2008 Share Posted March 28, 2008 im sorry, im rather tired as ive explained to others unfortunate enough to try the code i provide try this.. <?php include ("config.php"); error_reporting(E_ALL ^ E_NOTICE); session_start(); $msg = Array(); $error = Array(); function addUser(){ if (empty($_POST)) return false; global $config, $msg, $error; if(md5(strtoupper($_POST['code'])) !== $_SESSION['__img_code__']) $error[] = 'Invalid Code!'; if (empty($_POST['login'])) $error[] = 'Error, You forgot to enter a account name!'; if (empty($_POST['password'][0]) || empty($_POST['password'][1])) $error[] = 'Error, You forgot to enter a password!'; if ($_POST['password'][0] !== $_POST['password'][1]) $error[] = 'Password does not match!'; if (empty($_POST['email'])) $error[] = 'Please fill in a valid email adress!'; if (empty($_POST['code'])) $error[] = 'Error, You forgot to enter the code!'; if (!empty($error)) return false; $db = @mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']); if (!$db) return $error[] = 'Database: '.mysql_error(); if (!@mysql_select_db($config['mysql_dbname'], $db)) return $error[] = 'Database: '.mysql_error(); $query = "SELECT `acct` FROM `accounts` WHERE `login` = '".mysql_real_escape_string($_POST['login'])."'"; $res = mysql_query($query, $db); if (!$res) return $error[] = 'Database: '.mysql_error(); if (mysql_num_rows($res) > 0) return $error[] = 'Username already in use.'; $query = "INSERT INTO `accounts` (`login`,`password`,`lastip`, `email`, `flags`) VALUES ('".mysql_real_escape_string($_POST['login'])."', '".mysql_real_escape_string($_POST['password'][0])."', '".$_SERVER['REMOTE_ADDR']."', '".mysql_real_escape_string($_POST['email'])."', '8')"; $res = mysql_query($query, $db); if (!$res) return $error[] = 'Database: '.mysql_error(); $msg[] = 'The Account <span style="color:#00FF00"><strong>'.htmlentities($_POST['login']).'</strong></span> has been created!'; mysql_close($db); return true; } { addUser(); } include ("template.php"); session_start(); $ts = time(); ?> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Account Creation Page</title> <meta http-equiv="Pragma" content="no-cache"/> <meta http-equiv="Cache-Control" content="no-cache"/> <style type="text/css" media="screen">@import url(server_stats.css);</style> <!--[if lt IE 7.]> <script defer type="text/javascript" src="pngfix.js"></script> <![endif]--> </head> <body> <script language="JavaScript"><!-- ts = <?= $ts ?>; --></script> <center> <div class="logo"></div> <div style="width:300px"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <table width="100%" border="0" cellspacing="1" cellpadding="2"> <tr class="head"><th colspan="2">Account Creation</th></tr> <tr> <th>Username: </th><td align="center"><input class="button" type="text" name="login" size="30" maxlength="16"/></td> </tr> <tr> <th>Password: </th><td align="center"><input class="button" type="password" name="password[]" size="30" maxlength="16"/></td> </tr> <tr> <th>Retype Password: </th><td align="center"><input class="button" type="password" name="password[]" size="30" maxlength="16"/></td> </tr> <tr> <th>E-mail: </th><td align="center"><input class="button" type="text" name="email" size="30" maxlength="30"/></td> </tr> <tr> <th>Enter the code shown <a href="no_matter" onclick="document.getElementById('__code__').src = 'code.php?id=' + ++ts; return false">New Code</a></p></th><td align="center"><img id="__code__" src="code.php?id=<?= $ts ?></td> </tr> <tr> <th>Code</th><td align="center"><input class="button" type="text" name="code" size="30" maxlength="6"/></td> </tr> </table> <input type="button" class="button" value="Back" onClick="history.go(-1)" /> <input type="submit" value="Create" class="button"/> </form> <?php if (!empty($error)){ echo '<table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td class="error" align="center">'; foreach($error as $text) echo $text.'</br>'; echo '</td></tr></table>'; }; if (!empty($msg)){ echo '<table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td align="center">'; foreach($msg as $text) echo $text.'</br>'; echo '</td></tr></table>'; exit(); }; ?> </div> </center> </body> </html> Link to comment https://forums.phpfreaks.com/topic/98274-need-help-with-adding-image-validator-to-a-signup-fourm/#findComment-502870 Share on other sites More sharing options...
cosmoshell Posted March 28, 2008 Author Share Posted March 28, 2008 well it works just i have alot of random imput fields for every thing exept username scattered acrost the page http://wow666.hopto.org/imgval/reg.php Link to comment https://forums.phpfreaks.com/topic/98274-need-help-with-adding-image-validator-to-a-signup-fourm/#findComment-502879 Share on other sites More sharing options...
benjaminbeazy Posted March 28, 2008 Share Posted March 28, 2008 cant help ya there.. looks like the form is loaded from an include as well as directly in this script. get rid of one of them. Link to comment https://forums.phpfreaks.com/topic/98274-need-help-with-adding-image-validator-to-a-signup-fourm/#findComment-502881 Share on other sites More sharing options...
cosmoshell Posted March 28, 2008 Author Share Posted March 28, 2008 cant help ya there.. looks like the form is loaded from an include as well as directly in this script. get rid of one of them. ok now the mess disappeared must have been a browser error. thanks for the help. Link to comment https://forums.phpfreaks.com/topic/98274-need-help-with-adding-image-validator-to-a-signup-fourm/#findComment-502884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.