Jump to content

fullyloaded

Members
  • Posts

    133
  • Joined

  • Last visited

    Never

Everything posted by fullyloaded

  1. Hi, thanks everyone for all the help, it helped a lot.
  2. Hi, I've been working on my sign up form and am having a few problems getting it to work. First problem i'm having is this error: i think it has to do with the function being in the wrong place but could be wrong. My second problem is the errors array, if i leave any of the text box fields empty or if the passwords don't match it will still add the user to the database and not show the error messages. Thanks. require("db.php"); if(!empty($_POST)) { $errors = array(); if ($user == "") { $errors[] = "Please Enter A Username."; } if ($pass == "") { $errors[] = "Please Enter A Password."; } if ($confirmpass == "") { $errors[] = "Please Enter A confirmation password."; } if ($email == "") { $errors[] = "Please Enter Your E-mail Address."; } if ($comfirmemail == "") { $errors[] = "Please Enter Your Confirmation E-mail Address."; } if ($gender == "") { $errors[] = "Please Select A Gender."; } if ($month == "") { $errors[] = "Please Select A Month."; } if ($day == "") { $errors[] = "Please Select A Day."; } if ($year == "") { $errors[] = "Please Select A Year."; } if ($country == "") { $errors[] = "Please Select A Country."; } if ($firstname == "") { $errors[] = "Please Enter Your First Name."; } if ($lastname == "") { $errors[] = "Please Enter Your Last Name."; } if (strlen($pass) < $passLengthMIN ) { $errors[] = "The password contains to little chars."; } if (strlen($pass) > $passLengthMAX ) { $errors[] = "The password contains to much chars."; } if (strlen($user) < $userLengthMIN ) { $errors[] = "The username contains to little chars."; } if (strlen($user) > $userLengthMAX ) { $errors[] = "The username contains to much chars."; } if (validadres($email) == false ) { $errors[] = "The given e-mail address is not valid."; } if ($pass <> $confirmpass) { $errors[] = "Passwords do not match."; } if ($email <> $comfirmemail) { $errors[] = "Email Address do not match."; } $query = "SELECT id FROM users WHERE user = :user Or email = :email"; $query_params = array( ':user' => $_POST['user'], ':email' => $email ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $row = $stmt->fetch(); if ($row = $stmt->fetch($result)){ if ($row["user"] == $user) { $errors[] = "Your username is already used by another member."; } if ($row["email"] == $email) { $errors[] = "Your e-mail address is already registrated in our database."; } } if ($errors) { $errorstr = "<ul><li>" . implode("</li><li>", $errors) . "</li></ul>"; } else { $errorstr = ""; } $query = "INSERT INTO users (user,pass,salt,email,month,day,year,firstname,lastname,gender,country ) VALUES (:user,:pass,:salt,:email,:month,:day,:year,:firstname,:lastname,:gender,:country)"; $salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647)); $pass = hash('sha256', $_POST['pass'] . $salt); $query_params = array( ':user' => $_POST['user'], ':pass' => $pass, ':salt' => $salt, ':email' => $_POST['email'], ':month' => $_POST['month'], ':day' => $_POST['day'], ':year' => $_POST['year'], ':firstname' => $_POST['firstname'], ':lastname' => $_POST['lastname'], ':gender' => $_POST['gender'], ':country' => $_POST['country'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } /////////EMAIL VALID CODE//////////////////////// function validadres($email){ $prereturn = true; if (strlen($email) < 5){$prereturn = false;} $partsNumber = split("@",$email); if (count($partsNumber) <> 2) {$prereturn = false;} else{ list($user,$domain) = split("@",$email); if (strlen($user) < 1) {$prereturn = false;} } return $prereturn; } //////END////////////////////////////////////////// header("Location: login"); exit; }
  3. Hi, thank you very much, that fixed my problem.
  4. Hi, I have a big favor to ask, first anyone know why im getting this erro on line 4? and also im new to PDO and not that great at php is there anything in my code i should change to make it better? thanks. require("db.php"); $query = "SELECT * FROM users WHERE user = '$_SESSION['user']' AND pass = '$_SESSION['pass']'"; $query_params = array( ':user' => $_POST['user'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } if ($row = $stmt->fetch($result)){ $userid = mysql_result($result, 0, 'id'); $_SESSION['id'] = $id; $user_current_level = $row["userlevel"]; if ($reqlevel == 0 && $row["userlevel"] > 0){ header("Location: error"); exit(); }else{ if ($row["userlevel"] < $reqlevel && $row["userlevel"] > 0){ header("Location: levelerror"); exit(); } } if ($reqlevel == 0 && $row["userlevel"] > 0){ header("Location: error"); exit(); }else{ if ($row["userlevel"] < $reqlevel && $row["userlevel"] > 0){ header("Location: levelerror"); exit(); } } }else{die("<meta http-equiv='refresh' content='0;url=mysite.com'>"); } $user_currently_loged = htmlspecialchars($_SESSION["id"],ENT_NOQUOTES); $user_currently_loged = str_replace ('\"', """, $user_currently_loged); $user_currently_loged = str_replace ("\'", "&#039", $user_currently_loged); $user_currently_loged_plain = $_SESSION['user']; if ($user_current_level < 0){ $user_current_Rank = "Adminstrator"; }else{ $user_current_Rank = $ranks[$user_current_level]; } $query = "SELECT * FROM mymsgs WHERE sent = $_SESSION['user']"; $query_params = array( ':sent' => $_POST['sent'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $user_current_ammount_new = $stmt->fetch($result);
  5. hi thanks for the reply how would i go about stopping the second one from being executed if the first one fails? again thanks.
  6. Hey, I was wondering if its ok to have my code the way i have it below, 2 inserts one after the other? or is there a proper way of doing this any help would be great thanks. $query = "INSERT INTO users (user,pass,salt,email,firstname,lastname,gender,country,actnum ) VALUES (:user,:pass,:salt,:email,:firstname,:lastname,:gender,:country,:0)"; $salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647)); $pass = hash('sha256', $_POST['pass'] . $salt); $query_params = array( ':user' => $_POST['user'], ':pass' => $pass, ':salt' => $salt, ':email' => $email, ':firstname' => $firstname, ':lastname' => $lastname, ':gender' => $gender, ':country' => $country, ':actnum' => $actnum ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $query = "INSERT INTO users_msg_sent (user,emails,bdaygreetings,totalsent ) VALUES (:user,:0,:0,:0)"; $query_params = array( ':user' => $_POST['user'], ':emails' => $emails, ':bdaygreetings' => $bdaygreetings, ':totalsent' => $totalsent ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); }
  7. Hi, I'm having a little problem checking to see if a account has been activated or not. I don't know if i'm on the right track or not, here is what i got and what im trying to add. First is my login script, and second is what im trying to add to check if the account has been activated. Any help would be great thanks. Login script: session_start(); function returnheader($location){ $returnheader = header("location: $location"); return $returnheader; } include_once("db.php"); $errors = array(); if(isset($_POST["iebugaround"])){ $uname = trim(htmlentities($_POST['username'])); $passw = trim(htmlentities($_POST['password'])); if(empty($uname) || empty($passw)){ $errors[] = "$required_fields"; } if(!$errors){ $passencrypt = hash('sha512', $_POST['password']); $query = "SELECT * FROM members WHERE username='".mysql_real_escape_string($uname)."' AND password='".mysql_real_escape_string($passencrypt)."'"; $result = mysql_query($query) OR die(mysql_error()); $result_num = mysql_num_rows($result); if($result_num > 0){ while($row = mysql_fetch_array($result)){ $idsess = stripslashes($row["id"]); $firstnamesess = stripslashes($row["firstname"]); $username = stripslashes($row["username"]); $_SESSION["SESS_USERID"] = $idsess; $_SESSION["SESS_USERFIRSTNAME"] = $firstnamesess; $_SESSION["SESS_USERNAME"] = $username; setcookie("userloggedin", $username); setcookie("userloggedin", $username, time()+43200); returnheader("users.php"); } } else { $errors[] = "$incorrectLogin"; } } } else { $uname = ""; } Code trying to add(not sure if this is right): if ($row["actnum"] == "0"){ //Then login to site }else{ $errors[] = "$accountNotActivated"; }
  8. hi bleured27 thanks for the reply, i have search google and came up with a lot of scripts and have a captcha script. The code i posted (my captcha script) is the part im having problems adding to my script, i been watching tuts for 2 days and did learn a lot but still am having a problem with adding that bit of code.
  9. hi i was wondering if anyone can give me a hand adding this captcha script? i have tried everything i can think of with no luck at all. I think my problem has to do with the session where i already have one started but i could be wrong, any help would be great thanks. My code: <?php include("db.php"); $error_message=""; $email_to = mysql_real_escape_string(strip_tags($_POST['email_to'])); $today = date("M d, Y h:i A"); $ip = $_SERVER['REMOTE_ADDR']; if (isset($_POST['submit'])){ if($_SERVER['REQUEST_METHOD'] == 'POST') { if(!isset($_SESSION['csrf']) || $_SESSION['csrf'] !== $_POST['csrf']) $sql = "SELECT username FROM users WHERE mailaddress = '{$email_to}'"; $result=mysql_query($sql, $conn) or die('Error in query:<br>'. $sql .'<br>'.mysql_error($conn).'<br>Time of Error: '.date("l F j, Y, G:i:s T")); $count=mysql_num_rows($result); if($count==1){ $rows=mysql_fetch_array($result); $username=htmlentities($rows['username']); $to=$email_to; $subject="mysite Username reminder."; $header="from: noreply@mysite.com"; $messages= "Hey $username, \r\n"; $messages.=" \r\n"; $messages.="You recently request your mysite username on $today \r\n"; $messages.=" \r\n"; $messages.="Your username is: $username \r\n"; $messages.=" \r\n"; $messages.="You can sign in at: https://www.mysite.com \r\n"; $messages.=" \r\n"; $messages.="Your username was requested from the following ip address: $ip \r\n"; $messages.=" \r\n"; $messages.="Thanks, \r\n"; $messages.="From mysite.com \r\n"; $sentmail = mail($to,$subject,$messages,$header); } else { $error_message = 'Sorry email address not found.'; } if($sentmail){ $error_message = 'Your username has been sent to your email address.'; } else { $error_message = 'username was not sent please try again.'; } } } $key = sha1(microtime()); $_SESSION['csrf'] = $key; ?> Captcha code trying to add: <?php session_start(); if (md5($_POST['csrf']) == $_SESSION['csrf']){ $error_message = 'Captcha good.'; } else { $error_message = 'Captcha wrong.'; } ?>
  10. thanks a lot guy for the code and info.
  11. hi i was wondering if anyone has any idea how to read text from a database and if that text = "mytexthere" then goto header("Location: index.php"); sorry i have no code on this post reason is all the code i have tried on my own is crap
  12. hey anyone know how to fix the problem im having with my code? the first 10 lines of code is working great and doing what it should do but the rest of the code is not doing what i want it to do. what im trying to get it to do is select the packagelink from the database and go to that link thanks... <?PHP $username1 = @$HTTP_GET_VARS["username"]; $actnum1 = @$HTTP_GET_VARS["actnum"]; include("cfg.php"); $query = "Select * from ".$DBprefix."signup where username='$user_name1' And actnum='$actnum1'"; $result = mysql_query($query); if ($row = mysql_fetch_array($result)){ $query = "UPDATE ".$DBprefix."signup Set actnum = '0' where username='$username1'"; $result = mysql_query($query); $query = "Select * from ".$DBprefix."signup where username='$username1'"; $result = mysql_query($query); //CODE BELOW IS WHAT IM HAVING THE PROBLEM WITH// $result = mysql_query ("Select packages from ".$DBprefix."signup where username='$username1'"); $package = '$result'; $result2 = mysql_query("SELECT packagelink FROM packages WHERE packages ='$package'"); $link = '$result'; header("Location: '$link'"); } ?>
  13. hi i was wondering if anyone had any idea how i can add code A to code b below? code a is my captcha code and code b is my contact form code thanks.. CODE A CAPTCHA: <?php if(isset($_POST["captcha"])) if($_SESSION["captcha"]==$_POST["captcha"]) { echo 'CAPTHCA is valid; proceed the message'; } else { echo 'CAPTHCA is not valid; ignore submission'; } ?> CODE B CONTACT FORM: <? $mailto = "me@blah.com"; $cc = ""; $bcc = ""; $subject = "Email subject"; $vname = "blah blah"; $email = $_POST['email']; function validateEmail($email) { if(eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$', $email)) return true; else return false; } if(strlen($_POST['name']) < 1 || strlen($_POST['message']) < 1 || validateEmail($email) == FALSE) { $emailerror = 'Error:'; if(empty($_POST['name'])) { $emailerror .= '<li>Enter name</li>'; } if(validateEmail($email) == FALSE) { $emailerror .= '<li>Enter valid email</li>'; } if(empty($_POST['message'])) { $emailerror .= '<li>Enter message</li>'; } } else { $emailerror .= "Your email has been sent successfully"; $timestamp = date("F j, Y, g:ia"); $messageproper ="\n\n" . "Name: " . ucwords($_POST['name']) . "\n" . "Email: " . ucwords($email) . "\n" . "Comments: " . $_POST['message'] . "\n" . "\n\n" ; $messageproper = trim(stripslashes($messageproper)); mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" . phpversion() ); } ?>
  14. Thanks PaulRyan that worked great.
  15. hi here it is sorry browser_detection code: <?php function browser_detection( $which_test ) { $browser = ''; $dom_browser = ''; $navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : ''; if (stristr($navigator_user_agent, "mozilla")) { $browser = 'mozilla'; $dom_browser = true; } elseif (stristr($navigator_user_agent, "msie")) { $browser = 'msie'; $dom_browser = true; } elseif ((stristr($navigator_user_agent, "konqueror")) || (stristr($navigator_user_agent, "safari"))) { $browser = 'safari'; $dom_browser = true; } else { $dom_browser = false; $browser = false; } if ( $which_test == 'browser' ) { return $browser; } elseif ( $which_test == 'dom' ) { return $dom_browser; } } ?>
  16. hi i was wondering if anyone has any idea how to get this code to work for more then one browser? i can get it to work for one browser but have no luck on getting it to work for more then one browser thanks... code that don't work: <?php include("browserDetection.php"); $user_browser = browser_detection('browser'); if ( $user_browser == 'mozilla' ) { echo("<link href='style.css' type='text/css' rel='stylesheet'></link>\n"); } else { echo("<link href='style1.css' type='text/css' rel='stylesheet'></link>\n"); } if ( browser_detection('msie') ) { echo("<link href='style.css' type='text/css' rel='stylesheet'></link>\n"); } else { echo("<link href='style1.css' type='text/css' rel='stylesheet'></link>\n"); } ?> code that works: <?php include("browserDetection.php"); $user_browser = browser_detection('browser'); if ( $user_browser == 'Mozilla' ) { echo("<link href='style.css' type='text/css' rel='stylesheet'></link>\n"); } else { echo("<link href='style1.css' type='text/css' rel='stylesheet'></link>\n"); } ?>
  17. thanks everyone for your help QuickOldCar thats it that code worked out great again thanks.
  18. i have everything in the database setup correct i want to insert text in the same column as vidID text being a url so if i view vidID in the database i would see URLHEREvidID Thanks for the reply.
  19. hi i been working on this code witch will add what ever text i want to my database all is working great but what i am having problems with is inserting a url in the same field as vidID it will look like this in the database hxxp://xxx.mysitehere.com/index.php?vid=vidID hope you guys know what im talking about im having a hard time explaining it sorry. <?php $host="xxxxx"; $username="xxxxxxx"; $password="xxxxxxx"; $db_name="xxxxxxx"; $tbl_name="xxxxxxx"; $message = strtoupper(trim($_REQUEST['message'])); $sender = strtoupper(trim($_REQUEST['sender'])); $email = strtolower(trim($_REQUEST['email'])); $vidID =$_REQUEST['vidID']; mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="INSERT INTO $tbl_name(message,sender,email,vidID)VALUES('$message','$sender', '$email', '$vidID')"; $result=mysql_query($sql); ?>
  20. hi everyone i was wondering if anyone has any idea how i can make my php links look like this "wwwDOTmysiteDOTcom/xxx.php?s=account" right now they look like this "wwwDOTmysiteDOTcom/account.php" thanks...
  21. ok i did the php.ini error and this is what i got im hoping its easy to fix Use of undefined constant ADMIN_PATH - assumed 'ADMIN_PATH' in /home/***/startup.php on line 6 Use of undefined constant MYSQL_DB_HOST - assumed 'MYSQL_DB_HOST' in /home/***/config.php on line 8 Use of undefined constant MYSQL_DB_USER - assumed 'MYSQL_DB_USER' in /home/***/config.php on line 9 Use of undefined constant MYSQL_DB_PASS - assumed 'MYSQL_DB_PASS' in /home/***/config.php on line 10 Use of undefined constant MYSQL_DB_NAME - assumed 'MYSQL_DB_NAME' in /home/***/config.php on line 11 Constant ROW_PER_PAGE already defined in /home/***/startup.php on line 38 Undefined index: m_id in /home/***/startup.php on line 57 config.php MYSQL_DB_HOST => "***", MYSQL_DB_USER => "***", MYSQL_DB_PASS => "***", MYSQL_DB_NAME => "***" startup.php line 6 define(ADMIN_PATH,$script_path); line 38 define($_db->f('constant_name'),$_db->f('value')); line 57 $_db->query("UPDATE user SET action='".$time_stamp."' WHERE user_id='".$_SESSION[u_ID]."'");
  22. hi thanks for the fast reply yes i tried it on php5 and it will only show part of my site i checked the error log in my cpanel and there is no errors showing in there.
  23. hi im having a big problem with my site the problem is it will only run under php4 any one have any idea how much work it would be to make it compatible with PHP5 i know you might have to see the code but will PHP4 to PHP5 Converter work software work?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.