
Drummin
Members-
Posts
1,004 -
Joined
-
Last visited
Everything posted by Drummin
-
Do you apply a constant to the base as in the following? $base = dirname(__FILE__); $config = array{ 'database' => array( 'host' => 'localhost', 'user' => 'dbusername', 'password' => 'dbpw', ), 'email' => array( 'admin' => '[email protected]', ) etc. );
-
PHP sessions, and random strings. Help completing code.
Drummin replied to ibr4n's topic in PHP Coding Help
Well you do have a space after the EIGHT. -
Ya, I'd like to learn about building MVC framework as well. Let's go.
-
You're going to have $_POST['button'] as well so you might qualify $key before doing anything with it. I'm sure more qualified coders will have a more efficient code but try this. foreach($_POST as $key => $val){ IF (is_int($key)){ //DO SOMETHING WITH THIS $key ID// } }
-
PHP sessions, and random strings. Help completing code.
Drummin replied to ibr4n's topic in PHP Coding Help
I wonder why it put that smiley face on my post. Must be something from post above that got copied. In any case the line, if ($num == is missing the ... and seems to have that smiley face in it's place. Interesting. -
You're going to have to swap name and value so the unique id is for the name and pin is the value. On the pick up side of your post you will need to use a foreach statement to pick up the $key value. Something like this. foreach($_POST as $key => $val){ //DO SOMETHING WITH THIS $key ID// }
-
PHP sessions, and random strings. Help completing code.
Drummin replied to ibr4n's topic in PHP Coding Help
The value and ) for if ($num == is missing. -
sure, just query the table after you've validated the post. $getinfo = mysql_query("SELECT DATE, SITE, PRICE FROM daterange WHERE RID=$FTGRID "); WHILE ($resultinfo = mysql_fetch_array($getinfo)){ $date = ($resultinfo['DATE']); $site = ($resultinfo['SITE']); $price = ($resultinfo['PRICE']); }
-
You have a duplicate </head> tag on line 16 that should be removed. Try running your page through http://validator.w3.org/ to fix html errors.
-
Hey, better or worse, this is what I'm using. I have a separate table for users online aside from my "users" table. $timeoutseconds = 30; //get the time $timestamp = time(); $timeout = $timestamp-$timeoutseconds; //insert the values $insert = mysql_query("INSERT INTO ".$conf['tbl']['useronline']." (timestamp, ip, level, userid) VALUES ('$timestamp','$_SERVER[REMOTE_ADDR]','$_SESSION[secure_level]','$newID')"); if(!($insert)) { print "Useronline Insert Failed > "; } //delete values when they leave $delete = mysql_query("DELETE FROM ".$conf['tbl']['useronline']." WHERE timestamp<$timeout"); if(!($delete)) { print "Useronline Delete Failed > "; } //grab the results $resultall = mysql_query("SELECT DISTINCT ip FROM ".$conf['tbl']['useronline'].""); if(!($resultall)) { print "Useronline Select Error > "; } $userall = mysql_num_rows($resultall); Using the $userall query I go on to display total users. I then query again for each level.
-
The above actually came from a DUMP and I don't recall adding it initially but that was a year or so ago. Possibly the default MySQL setting. I think you should add the level field to qualify the user logging in and directing them to the proper section. Maybe think of it as level1 has registered but not approved or has been banned, level2 is a user and level3 will be for you down the road when you work on that Admin section.
-
So you need a database table for users. I would suggest using these fields. id int(11) NOT NULL AUTO_INCREMENT, user varchar(20) NOT NULL, userfirst varchar(20) NOT NULL, //Remove if you don't want this info on registration form BUT it's good to have names for email etc. userlast varchar(20) NOT NULL, //Remove if you don't want this info on registration form BUT it's good to have names for email etc. mi varchar(1) NOT NULL, //Remove if you don't want this info on registration form BUT it's good to have names for email etc. pass char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, email varchar(255) DEFAULT NULL, phone varchar(18) NOT NULL, //Remove if you don't want this info on registration form BUT it's good to have in some venues. level varchar(2) DEFAULT NULL, Do you know how to create these tables with a script and add the "Admin" user?
-
Wonderful it's working for you!
-
What he's saying is that you should setup email accounts with your host for [email protected], [email protected] and [email protected]. My host allows mail() along with SMTP. My hosting does require this as well, so if your domain is rustyeckford.com you should be able to add an address for "me", "me1" and "me2".
-
Looks like I used semi-colons instead of colons in the switch. I don't use switches much, sorry about that. I think it should be switch($state) { case 'Kansas': case 'Oklahoma': $wm = $webMaster2; break; case 'Missouri': case 'Iowa': $wm = $webMaster3; break; case 'Nebraska': $wm = $webMaster; break; }
-
Then I would get rid of $success = ... as I assumed you were using it somewhere else. Just use mail($wm, $emailSubject, $body, $headers);
-
You REALLY need to validate your input! There are were errors in your switch. In any case, see if this works. <?php /* Subject and Email variables */ $emailSubject = 'Your Car Report Info.'; $webMaster = '[email protected]'; $webMaster2 ='[email protected]'; $webMaster3 ='[email protected]'; /* Gathering Data Variables */ IF ($_POST){ $f_name = $_POST['f_name']; $l_name = $_POST['l_name']; $add = $_POST['Address']; $state = $_POST['state']; $phone = $_POST['phone']; $email = $_POST['email']; $vin = $_POST['vin']; }//END IF POST //********VALIDATE POST!!!!!!******// //if values are good// IF ((!empty($f_name)) && (!empty($l_name)) && (!empty($add)) && (!empty($state)) && (!empty($phone)) && (!empty($email)) && (!empty($vin))){ $body = "<br><hr><br>First Name: $f_name <br>Last Name: $l_name <br>Address: $Address <br>State: $state <br>Phone: $phone <br>Email: $email <br>VIN: $vin<br>"; switch($state) { case 'Kansas'; case 'Oklahoma'; $wm = $webMaster2; break; case 'Missouri'; case 'Iowa'; $wm = $webMaster3; break; case 'Nebraska'; $wm = $webMaster; break; } $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($wm, $emailSubject, $body, $headers); /* Results rendered from Html */ ?> <html> <head> <title>Your Car Report - Results</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } </style> </head> <div> <div align="center">Thank you for your submission. Your vehicle report will be provided to you very soon!</div> </div> </body> </html> <?PHP } ?>
-
Looks like you're missing grabbing the value of id. Add this to the top of klub.php. $id=$_GET['id'];
-
Curious xyph if your function takes into account an odd number of characters. Split in half give you a decimal value, 62.5 etc. Just wondering.
-
Forgive me for butchering your code. I'm not Sure about GetSQLValueString(). I believe it is a Dreamweaver custom-built function and not part of php. I will change your code to make the query using an id grabbed from $_GET['home']. Again, this code works fine for me when I use my own table query but when using GetSQLValueString() I get nothing. This is why I made the change. Take it or leave it. <?php //NOT Sure about GetSQLValueString(). I believe it is a Dreamweaver custom-built function and not part of php. I will change your query// //******************************************************************// //function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") //{ // $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; // switch ($theType) { // case "text": // $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; // break; // case "long": // case "int": // $theValue = ($theValue != "") ? intval($theValue) : "NULL"; // break; // case "double": // $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; // break; // case "date": // $theValue = ($theValue != "") ? "'" . date("Y-d-m",strtotime($theValue)) . "'" : "NULL"; // break; // case "time": // $theValue = ($theValue != "") ? "'" . date("H:i:s",strtotime($theValue)) . "'" : "NULL"; // break; // case "datetime": // $theValue = ($theValue != "") ? "'" . date("Y-d-m H:i:s",strtotime($theValue)) . "'" : "NULL"; // break; // case "defined": // $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; // break; // } // return $theValue; //} //$colname_hometext_RS = "-1"; //if (isset($_GET['home'])) { // $colname_hometext_RS = $_GET['home']; //} mysql_select_db($database_MySQLconnect, $MySQLconnect); //NOT Sure about GetSQLValueString(). I believe it is a Dreamweaver custom-built function and not part of php. I will change your query// //******************************************************************// //$query_hometext_RS = sprintf("SELECT * FROM t_textos WHERE id_texto = %s", GetSQLValueString($colname_hometext_RS, "int")); //$hometext_RS = mysql_query($query_hometext_RS, $MySQLconnect); // or die(mysql_error()) //$row_hometext_RS = mysql_fetch_assoc($hometext_RS); //$totalRows_hometext_RS = mysql_num_rows($hometext_RS); //********************************************// ///I will assume you are using $_GET['home'] to grab an id number// //********************************************// if (isset($_GET['home'])) { $id = $_GET['home']; } $query_hometext_RS = mysql_query("SELECT * FROM t_textos WHERE id_texto = $id"); WHILE($hometext_RS = mysql_fetch_array($query_hometext_RS)) { $textoesp=$hometext_RS['texto_esp']; } //*********TEST*********// //Are you getting full text when echoing $textoesp echo "$textoesp"; ///END TEST-REMOVE if shown/// $charcount = strlen($textoesp); $mid = number_format($charcount/2, 0, '.', ''); $halflast = $mid-1; $cut = strpos($textoesp , " " , $halflast); $part1= substr($textoesp , 0 , $cut); $part2= substr($textoesp , $cut , $charcount); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { margin-top: 0px; } --> </style> <link href="styles/cantera_styles.css" rel="stylesheet" type="text/css" /> </head> <body> <?php echo "<table><tr>"; // First column echo "<td>$part1</td>"; echo "<td style='width:30px'></td>"; // Second column echo "<td>$part2</td>"; echo "</tr></table>"; require_once('footer.php'); ?> </body> </html>
-
OR a more simple approach. <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . date("Y-d-m",strtotime($theValue)) . "'" : "NULL"; break; case "time": $theValue = ($theValue != "") ? "'" . date("H:i:s",strtotime($theValue)) . "'" : "NULL"; break; case "datetime": $theValue = ($theValue != "") ? "'" . date("Y-d-m H:i:s",strtotime($theValue)) . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $colname_hometext_RS = "-1"; if (isset($_GET['home'])) { $colname_hometext_RS = $_GET['home']; } mysql_select_db($database_MySQLconnect, $MySQLconnect); $query_hometext_RS = sprintf("SELECT * FROM t_textos WHERE id_texto = %s", GetSQLValueString($colname_hometext_RS, "int")); $hometext_RS = mysql_query($query_hometext_RS, $MySQLconnect) or die(mysql_error()); $row_hometext_RS = mysql_fetch_assoc($hometext_RS); $totalRows_hometext_RS = mysql_num_rows($hometext_RS); $textoesp=$row_hometext_RS['texto_esp']; $charcount = strlen($textoesp); $mid = number_format($charcount/2, 0, '.', ''); $halflast = $mid-1; $cut = strpos($textoesp , " " , $halflast); $part1= substr($textoesp , 0 , $cut); $part2= substr($textoesp , $cut , $charcount); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { margin-top: 0px; } --> </style> <link href="styles/cantera_styles.css" rel="stylesheet" type="text/css" /> </head> <body> <?php echo "<table><tr>"; // First column echo "<td>$part1</td>"; echo "<td style='width:30px'></td>"; // Second column echo "<td>$part2</td>"; echo "</tr></table>"; require_once('footer.php'); mysql_free_result($hometext_RS); ?> </body> </html>
-
echo repopulating blank data in database on refresh. please help
Drummin replied to bremen1984's topic in PHP Coding Help
Is the textarea within your $result array? You should be able to see the description by just echoing the line without a textarea. Can you see the "description"? echo '<p>Description: ' . $_result['description'] . '</p>'; -
Sure, I know that, but he's looking for $_POST['join']. I was just pointing out that there is an id being added to the join name.
-
You're looking for the value "join" but are submitting "joinid". Why not put company id in another field? <form method="post" id="ccreateform" class="man"> <input type="hidden" name="companyid" value="<?php echo $company['companyid']; ?>" /> <input type="submit" name="join" value="Join" /> </form>
-
I Need Some Help Filtering Search Results Using Dropdowns!
Drummin replied to designer76's topic in PHP Coding Help
Shouldn't those if statements be bracketed? $arr = new array(); // color if(!empty($_POST['color']){ $arr[] = "color = '".$_POST['color']."'"; } // type if(!empty($_POST['type']){ $arr[] = "type = '".$_POST['type']."'"; } // size if(!empty($_POST['size']){ $arr[] = "size = '".$_POST['size']."'"; } $str = implode(" and ", $arr);