
benjaminbeazy
Members-
Posts
460 -
Joined
-
Last visited
Never
Everything posted by benjaminbeazy
-
if you want to change the name of the variable itself, use a variable variable ie for($i=0;$i<10;$i++){ $name = 'a'.$i; $$name = 'wjatever'; } echo $a9; outputs "wjatever"
-
change if ($find == "") to if ($_POST['find'] == "")
-
Get data from mysql table from different records of a field
benjaminbeazy replied to jkkenzie's topic in PHP Coding Help
$result = mysql_query("SELECT * FROM tblkenya ORDER BY ID ASC LIMIT 19"); while($row = mysql_fetch_assoc($result)) { $rows[] = $row; } foreach($rows as $key => $array){ echo '<pre>'; print_r($rows[$key]); echo '</pre>'; //or echo $rows[$key]['somecolumname']; } //or foreach($rows as $array){ foreach($array as $key => $val){ echo "$key = $val<br>"; } } //u get the picture -
$zip = $_POST['fname']; if (empty($city)) { $errors[] = 'Please enter a zip'; } that code should be fixed, but the real problem is that your action points to a totally new script. hence none of the validation contained on this page will be processed as it's all sent to NewCarquoteform.php have the form point back to itself and validate it, then set a session var or something when everything is validated and do a header redirect... that would be the easy way with spaghetti code such as this
-
the actual placement of the image inside the textarea is javascript.
-
Array ( [”zipcode”] => hjg ) Warning: Cannot modify header information - headers already sent by (output started at /home/content/r/g/a/rgarri33/html/submitform.php:2) in /home/content/r/g/a/rgarri33/html/submitform.php on line 4 Your Zip Code appears to be invalid. Please go back and try again. looks like something is working...
-
for($i=0;$i<10;$i+2){ //put anything you wanna loop in here //change 0 and 10 to whatever you want and reference $i anywhere you need to } is that what u mean?
-
are you getting errors?
-
fclose($fh); for future reference, you should mention what happens. ie error msg, etc.
-
javascript could do that...
-
switch($warranty){ case '100': $date_purchase = 1*24*60; break; case '102': $date_purchase = 2*24*60; break; } follow that format
-
if you use 1 form, as the other guy said. use javascript and change you submit buttons to regular buttons. on clicking one of those, have javacript change the form action and submit the form...
-
is your problem the parse error here.... if so... add a parenthesis to the end of this line..... if(($tru) && (!mysql_fetch_row(mysql_query("SELECT round FROM '{$tab['game']}' WHERE round='$tru' AND starts<$time AND ends>$time;"))))
-
if you're not providing direct access to the files, i.e. you're using a script to access each file and the actual paths are hidden.. then you can limit the number of downloads within a given timeframe, but as far as verifying that the file download is complete, you would need something more elaborate..
-
you're missing a parenthesis after your long if statement...
-
yeah, if for some reason you need both buttons in one set of <form> tags
-
use one form for each submit button like... <form method="post" action="whateever"> <input type="hidden" name="id" value="someid"> <input type="hidden" name="action" value="insert"> <input type="submit" value="insert"> </form> <form method="post" action="whateever"> <input type="hidden" name="id" value="someid"> <input type="hidden" name="action" value="delete"> <input type="submit" value="insert"> </form> then grab the action and id(if applicable) from the hidden posted fields and process the request as such.
-
How do you write to a db from a sub domain?
benjaminbeazy replied to ballhogjoni's topic in PHP Coding Help
must be the host setting for user priveleges in mysql. if you have phpmyadmin.. click the home icon, click priveleges, click the edit box next to your user and see what the host is.. the host may be your domain as opposed to localhost or an ip. if so, change it to localhost -
Need help with adding Image Validator to a signup fourm
benjaminbeazy replied to cosmoshell's topic in PHP Coding Help
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. -
u could also natsort, but that may affect your execution time with a lot of records...
-
Need help with adding Image Validator to a signup fourm
benjaminbeazy replied to cosmoshell's topic in PHP Coding Help
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> -
i guess i would need to see the actual code to be able to tell what's going on
-
man you're picky i'm tired, youll have to forgive my lack of foresight. this should fix that $string = ' ""You cannot rea,lly call this "data"", " ", "more crap", " "'; $parts = explode('",', $string); for($i=0;$i<count($parts);$i++){ $val = trim($parts[$i]); if($val == '"'){ $parts[$i] = NULL; }else{ $parts[$i] = substr_replace($val, '', 0, -(strlen($val)-1)); } if( ($i+1) == count($parts) ){ $parts[$i] = substr($parts[$i],0,-1); $val = trim($parts[$i]); if($val == '') $parts[$i] = NULL; } } print_r($parts); im absolutely positive it could be a little more efficient, but it does the job...
-
Need help with adding Image Validator to a signup fourm
benjaminbeazy replied to cosmoshell's topic in PHP Coding Help
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>