Jump to content

SN1P3R_85

Members
  • Posts

    90
  • Joined

  • Last visited

    Never

Everything posted by SN1P3R_85

  1. I am having a problem with a php script. I want it take the text, and convert all the html tags into literal text. By this i mean if i have a string: <?php $str = "hello<br /><br />hello" ?> I want it to print to the screen as hello<br /><br />hello. My script automatically prints it as an html entity, so it will actually do a line break in the string container. However, my script detects line breaks in the php and puts <br /> in, so I need to somehow take the string, convert it to straight text, then be able to still add html, and have it display as html. Thanks, SN1P3R_85
  2. You guys are incredibly ignorant. You do realize that most programmers don't know everything, and need to get help from sites like these. If he can write code successfully with help from this site, why should it matter? You'd be surprised how many programmers who post on here are posting from their work, myself included. Everyone does it, why ignore a perfectly accessible resource?
  3. I fixed it, i cut and pasted the code back, and it somehow worked, lol. I'm guessing it was some kind of server error.
  4. I didnt' realize how large the code was, session that won't set is at bottom of code.
  5. I made a program that generates random passwords for a user if they want to have their password reset. At the end, i make an array, and save its value into a session var. For some reason, the session var wont' set. <?php session_start(); include( 'SQL_PASS.inc' ); $valid = $_SESSION['passresetvalid']; $id = $_SESSION['id']; if ($valid == false) { //gonna put ip logger here die('There was an error, password was not reset'); exit(); } srand ((double) microtime( )*1000000000000); $password = "" . rand(0, 9) . ""; $alphabet = 'abcdefghijklmnopqrstuvwxyz'; $digits = 10; $digits = $digits - 2; while ($digits >= 0) { $alphanum = rand(1, 50); $alphanum = $alphanum % 2; if ($alphanum == 1) { $password .= "" . rand(0, 9) . ""; } else { $casenum = rand(1, 50); $casenum = $casenum % 2; $letter = $alphabet[rand(0, 26)]; if ($casenum == 1) { $letter = strtoupper($letter); } $password .= "" . $letter . ""; } /*for($x=5; $x<=rand(50, 100); $x++) { echo ""; for($y=5; $y<=rand(50, 100); $y++) { echo ""; for($z=5; $z<=rand(50, 100); $z++) //extra delay { echo ""; } } }*/ $digits--; } if (!$con) { die('Could not connect to database: ' . mysql_error()); //if cannot connect, kills program and displays msg } elseif (!$db_select) { die('Could not select database: ' . mysql_error()); //if cannot select db, kills program and displays msg } $query = "UPDATE `users` SET Password='$password' WHERE Id='$id'"; $result = mysql_query($query); if (!$query) { die('major error has occured'); exit(); } $query = "SELECT * FROM `users` WHERE Id='$id'"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $recipient = $row['Email']; $subject = 'lost password'; $mailbody = 'Hello ' . $row['Username'] . ',<br />Your password has been successfully reset. Your new password is: <b>' . $password . '</b> . I reccommend that you change it, and you can do that at the control panel on your account.'; $header = "From: www.*********.com\n"; $header .= "To: " . $recipient . "\n"; $header .= "MIME-Version: 1.0\n"; $header .= "Content-type: text/html; charset=iso-8859-1\n"; $email_msg = mail($recipient, $subject, $mailbody, $header); } if (!$email_msg) { die('Error sending email'); } $message = "Your password has been successfully changed. An email has been sent with your new password. We recommend that you change your password as soon as you get your new one. You will now be redirected back to the homepage in "; $delay = 5; $location = "http://www.caidenhome.com"; $redirdata = array($message, $delay, $location); $_SESSION['redirpack'] = $redirdata; // THIS IS THE SESSION THAT WON'T SET, RIGHT HERE !!!! unset($_SESSION['passresetvalid']); unset($_SESSION['id']); header("location: http://www.********.com/redirect.php"); exit(); ?>
  6. the problem isn't that i can't get the session to set, its that the row['Userlevel'] doesn't seem to exist. I tested it by putting this in : echo $row['Userlevel']; and it still didn't work.
  7. I did, its up above, i didn't show the entire code
  8. Hi, I have a script where people can register on my site, and it works, but there is a problem with it. If the register goes through, it is supposed to log them on as well. On my site logging on consists of three parts, username, userlevel, and validate. I set three php sessions with these values. It sets the username and validate fine, but it won't set userlevel. Userlevel is in the same table as username, so I don't know why it won't work. However, when i use the login script, it sets it. $query = "INSERT INTO `users` (Username, Password, Userlevel, Email) VALUES ('$username', '$password', '$usr_level', '$email')"; $result = mysql_query($query); if ($result) { $_SESSION['username'] = $row['Username']; $_SESSION['userlevel'] = $row['Userlevel']; $_SESSION['uservalid'] = true; echo "registration successful, you are a " . $row['Userlevel'] . "."; }
  9. I have an email program, and have gotten it to mostly work, except that hotmail marks emails from my site as dangerous. Why is this? From what I've read, there is something wrong with my header. This is the part that needs fixing: $recipient = $row['Email']; $subject = 'lost password'; $mailbody = 'blah'; $header = "To: " . $row['Email'] . "\n"; $header .= "From: www.caidenhome.com <myemail@hotmail.com>\n"; $header .= "MIME-Version: 1.0\n"; $header .= "Content-type: text/html; charset=iso-8859-1\n"; $header .= "X-Priority: 1\n"; $header .= "X-MSmail-Priority: High"; $email_msg = mail($recipient, $subject, $mailbody, $header);
  10. Do i just add it anywhere in the header? What is the syntax for adding it, right now my header is this: $header = "From: www.caidenhome.com \r\n";
  11. Sounds like you didn't even write this code. Php freaks is so people can get help with a specific problem. You have to narrow it down, and then ask a specific question. You can't just expect people to debug a huge piece of code when you didn't even tell them what the problem is.
  12. Hi, i am having trouble with the basic format of putting a link inside an email message. When i get the email, it just has the <a href> listed out in text. I just want the link name to appear. How do you fix this?
  13. I made a basic login php script. The script works fine except for one small error. I made it so if the either the username or password input boxes are empty when the form is posted, it will set a SESSION called response. Then it redirects back to the page that they logged in on, and prints the $_SESSION['response']. The problem im having is that I use the response session for all my errors, and when the username or password does not exist in the database, it sets the response. This second error is overriding the first, so even if the username or password length = 0, then it will still set the second error value. If i comment out the second error, it will display the first one. Oh, i and know an easy way to fix this would be to just add someone to the mysql table named username: "" password: "" but i want to find out what's really wrong with it. Here is the code: <?php session_start(); include( 'SQL_PASS.inc' ); $url = $_SESSION['lastpage']; //variables are last page person was on, username, and password, respectively $username = $_POST['username']; $password = $_POST['password']; $username = mysql_real_escape_string($username); //protecting from mysql injection hackers!!! $password = mysql_real_escape_string($password); if (strlen($username)<=1 || strlen($password)<=1) //checking to see if username or password are unset { $_SESSION['response'] = 'please fill all the fields'; //setting error msg, and redirecting to lastpage header("Location: $url"); } elseif (!$con) { die('Could not connect to database: ' . mysql_error()); //if cannot connect, kills program and displays msg } elseif (!$db_select) { die('Could not select database: ' . mysql_error()); //if cannot select db, kills program and displays msg } $query = "SELECT * FROM `users` WHERE Username='$username' AND Password='$password'"; //making a query with username and password $result = mysql_query($query); if (!$result) { die('Could not run query: ' . mysql_error()); } elseif (mysql_num_rows($result)==0) //if username or password do not exist, then sets error msg, and redirects to last page { $_SESSION['response'] = 'Name or password is wrong, please try again'; header("Location: $url"); } while ($row = mysql_fetch_array($result)) //sets user info { $_SESSION['username'] = $row['Username']; $_SESSION['userlevel'] = $row['Userlevel']; $_SESSION['uservalid'] = true; } mysql_free_result($lgn_result); //free result because table is large and takes alot of memory header("Location: $url"); //redirect to last page ?>
  14. c'mon, are u telling me that none of you can help me with this problem.
  15. This isn't really a php question, but im tired of posting on the javascript page and having to wait an hour till i even get a single reply. Im sure many of you know javascript if you know php. In a code, i am calling different css files based on the browser type. What it does so far is call the css file, but doesn't execute any of the html, so i get a background color, and thats it. I call the js function in the body tag: <body onLoad="check_brwz();"> here is the javascript code: <script type="text/javascript"> <!-- function check_brwz() //checks for browser type so it will apply the correct style format { function browser() //sets browser name and version { this.name = navigator.appName; this.version = navigator.appVersion; } browse = new browser(); if (browse.name == 'Netscape') //sets the correct style format { document.write('<link rel="stylesheet" type="text/css" href="/css/moz_main.css" />'); document.write("hello"); } else if (browse.name == 'Microsoft Internet Explorer') { document.write('<link rel="stylesheet" type="text/css" href="/css/ie_main.css" />'); } else if (browse.name == 'Opera') { document.write('<link rel="stylesheet" type="text/css" href="/css/opera_main.css" />'); } else //default style format if browser type is unkown { alert('your browser is too old or unkown, settings will be set by default to fit Mozilla'); document.write('<link rel="stylesheet" type="text/css" href="/css/moz_main.css" />'); } alert(browse.name); } //--> </script>
  16. i don't mind if its more than one div. I just want the picture to line the left side, and right right side. I know how to make the image repeat vertically, and i know how to make it on the left side, but i want to do the exact same thing on the right side. Basically, my page would have the picture repeated on the left, and the right at the same time. divs aren't neccesarily the way to go, i just thought they may be.
  17. Hi, im trying to repeat two images vertically, one on the left side, and on on the right. It would create a kind of border, but i can't seem to do both. I am new to divs, and read that they would be best for multiple images. any ideas?
  18. oh, i didn't know there was an html forum, lol
  19. ok, this isn't php related, but anyone who knows php probably knows some html, so i thought i would find some help here. What i want to do is repeat an image vertically on the left side, and on the right. So basically create a kind of image border. I am pretty new to divs, and i couldn't seem to do this throught css. I want the same image for both sides, any ideas?
  20. thanks alot man, im still fairly new to php, started it around a month ago.
  21. im pretty sure the part thats messing it up is this, because when i comment it out, the page displays fine. echo '<table class="forum_menu" border="1" width="10%">'; while ($row = mysql_fetch_assoc($sql_query)) { echo '<tr style="height:20px"><td class="forum" width="50%"><a href="/forum/forum_display.php?id=' . $row['Thread_id'] . '>' . $row['Thread_name'] . '</td></tr>'; } echo "</table>";
×
×
  • 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.