Jump to content

slpctrl

Members
  • Posts

    173
  • Joined

  • Last visited

    Never

Everything posted by slpctrl

  1. I just wonder if I could do the above without the sprintf() function...that function really confuses me, not sure what it's doing. Would that be possible?
  2. Got it easier than I thought, a simple: <html> <body> <center><br /><br /><br /><br /> <form action="" method="post" /> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="pass" /><br /> Email: <input type="text" name="email" /><br /> <input type="submit" /> </form> </center> <?php if (isset($_POST['username']) && isset($_POST['pass']) && isset($_POST['email']) && !empty($_POST['username']) && !empty($_POST['pass']) && !empty($_POST['email'])) { $con = mysql_connect("localhost","root",""); if(!$con) { die("Couldn't connect to DB: " . mysql_error()); } $password = md5($_POST['pass']); mysql_select_db("info", $con); $check = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_array($check)){ if($row['UserName'] == $_POST['username'] || $row['email'] == $_POST['email']){ die("That username or email is already in use!"); } } mysql_query("INSERT INTO users (UserName, PassWord, email) VALUES('$_POST[username]', '$password', '$_POST[email]')"); mysql_close($con); } die(""); ?> Did the trick.
  3. Alright, I have this script (very basic, trying to refresh my memory on PHP/SQL and such): <html> <body> <center><br /><br /><br /><br /> <form action="" method="post" /> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="pass" /><br /> Email: <input type="text" name="email" /><br /> <input type="submit" /> </form> </center> <?php if (isset($_POST['username']) && isset($_POST['pass']) && isset($_POST['email']) && !empty($_POST['username']) && !empty($_POST['pass']) && !empty($_POST['email'])) { $con = mysql_connect("localhost","root",""); if(!$con) { die("Couldn't connect to DB: " . mysql_error()); } $password = md5($_POST['pass']); mysql_select_db("info", $con); mysql_query("INSERT INTO users (UserName, PassWord, email) VALUES('$_POST[username]', '$password', '$_POST[email]')"); mysql_close($con); } die(""); ?> But, what I want to do is to check the DB first, try to match the information trying to be submitted, and if it exists, stop the information from inserting into the DB. But, can't seem to wrap my head around a simple way. Any help would be appreciated .
  4. ^That actually wasn't my password thank god, but I do use it somewhere . Anyways, I got it thanks all .
  5. Thanks for removing those details...after a second I realized, oh sh...oh wow, why did I not filter those out x_x
  6. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } $user = "********"; $pass = md5("********"); $email = "******@live.com"; mysql_select_db("users", $con) or die("unable to select DB"); mysql_query("INSERT INTO users (user, pass, email) VALUES ('$user', '$pass', '$email')") or die("Can't insert info into DB " mysql_error()); mysql_close($con); ?> mod edit: removed user/pass/email details
  7. I've recently been getting back into PHP, and I've racked my brain over this incredibly simple piece of code, and can't figure out why I can't insert. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } $user = "********"; $pass = md5("********"); $email = "******@live.com"; mysql_select_db("users", $con) or die("unable to select DB"); mysql_query("INSERT INTO users ('user', 'pass', 'email') VALUES ($user,$pass,$email)") or die("Can't insert info into DB " mysql_error()); mysql_close($con); ?> I know my error is within the insert command...I just don't understand why this isn't working. I've even copied the code straight from W3schools, and it still doesn't work. My MYSQL version is 5.5.24 mod edit: removed user/pass/email details
  8. Doesn't work; I've got it down to this: <?php $num = array(); For ($i = 1000; $i > 0; $i--){ if ((($num % 3) != 0) || (($num % 5) != 0)) { array_push($num, $i); } echo array_sum($num); ?> I would think that'd work; but it doesn't. I've tried it with % and with /, nothing. When I insert that line just in my code, and move the code around so that it works it just echoes 1000 twice. :\
  9. First off, here's the script: <?php $num = array(); For ($i = 1000; $i > 0; $i--){ if !($num/3) && || !($num/5) { $i--; } else{ array_push($num, $i); echo "$i\n"; $i--; } } echo array_sum($num); ?> Now, what I'm trying to do is store every number under 1000 divisible by 3 or 5 into an array, and then add all the values in the array together; however, it doesn't work and I can't pinpoint where the error is. Any help is appreciated. Edit: Also, I have the echo "$i\n"; in there to help with finding the error; it echoes nothing :\.
  10. Alright, I've got this simple little script here: <?php //draws the image and stuff. . . $im = @imagecreatefrompng( "babe.png" ); header( "Content-type: image/png" ); imagepng($im); imagedestroy($im); ?> This works fine when it's saved as a .php, but when I save it as a .gif file (and this is my .htaccess: AddHandler application/x-httpd-php .png ) So, it should parse .php even with the .gif extension, but as a .php file it works fine, just as it should but as a .gif file it says can not display this image because it contains errors.
  11. How would I go about doing this? I know that it's gotta be simple, I just can't seem to find it via google and my brain can't come up with it . So, how do I just select the highest primary key and store it into a variable? ???
  12. Of course you can do it yourself! But now for the bad news: SEO is kind of a niche it's self, and something that needs to be learned entirely, kind of like learning to code. It's going to be a long haul to be honest, knowing nothing about SEO and a decent SEO agent can command thousands of dollars good work. Good luck .
  13. Hi, would anyone know where to get a PHP/flash driven app that allows you to do graphics and art? Are there any public ones? Just curious, I really don't have the time to take something like this on.
  14. Thank you so much! It's weird though, sometimes there's the border (represented by 10 0s) is still there, sometimes it's not, and sometimes there's just one or 2 extra 0s on the end. But this is as close as I'm gonna get probably, thanks!
  15. Here is my code: <?php function getpixels($pic){ //Create a new image inside of the program to examine $image = imagecreatefrompng($pic); //get dimensions of said image list($width, $height) = getimagesize($pic); //Divides the height by 2 so that we're taking a 1 pixel slice from the MIDDLE $height = $height/2; //Creats an array called vars to store the digits representing the colors across $vars = array(); //Loops the program until it gets all the way to the end of the image for ($i=0; $i<=$width; $i++){ //Get's the color of the current position $color = imagecolorat($image, $i, $height); //uses array push to force the color of the current position to the end of the array array_push($vars, $color); } //Makes the function return the array return $vars; } $pixls = getpixels("barcode.png"); for ($y=0; $y<10; $y++){ unset($pixls[$y]); } $num = array_sum($pixls); $num1 = (count($pixls))-(10); for ($x=$num1; $x<$num; $x++){ unset($pixls[$x]); } foreach($pixls as $pixl){ echo $pixl; } $codes = array("0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011"); ?> (Don't worry about the $codes array, it's an array of barcode codes representing 1-9, but that'll come later when I can get the array that I'm working with properly stripped. There is a white border, represented by 0s. 10 on each side; I need to remove both from each side, and I for the life of me can't get it to work.
  16. Alright, I've been having a really really tough time trimming all the extra zeros at the end of an array that I've got. Here is what I'm trying to do: <?php for ($y=0; $y<10; $y++){ unset($pixls[$y]); } $num = array_sum($pixls); $num1 = (array_sum($pixls))-(10); for ($x=$num1; $x<$num; $x++){ unset($pixls[$x]); } ?> The first one works, the second doesn't and I can't for the life of me figure out why. Might anyone know why this code doesn't work? ???
  17. The questions I'm asking are really to bigger problems I'm having with the code; to say I've asked for help the entire bit of the way is ridiculous. I thought that my result was supposed to be in binary, and it's not. Even with stripping the border, I can't seem to do anything with it anyways. The 0s are the white space, 1s are black. I need to strip the borders off of that (done), and then calculate the UPC number of the barcode and I don't know how to even begin analyzing this to find out the UPC number. I would go straight on the HBH forums to ask for help, but only one person has solved this challenge.
  18. I just ask, and I don't even know why. 99.9% of the time I have it before anyone replies. I need to quit doin that. And, I've only asked for help twice. Don't have a hissy fit, nancy.
  19. Alright, this is a continuation from my last thread, so sorry if that's frowned upon or whatever. Here's my code as it stands: <?php function getpixels($pic){ $image = imagecreatefrompng($pic); list($width, $height) = getimagesize($pic); $height = $height/2; $vars = array(); for ($i=0; $i<=$width; $i++){ $color = imagecolorat($image, $i, $height); array_push($vars, $color); } return $vars; } $pixls = getpixels("http://www.hellboundhackers.org/challenges/timed/timed7/barcode.php"); foreach($pixls as $pixl){ echo $pixl; } ?> And it's output (for what I'll be doing) should look something like so: 0000000000101010111101011110010011011110100010110111101010101101100100001011101001100110101110011100101010000000000 Now, I need to remove the initial zeros and the zeros on the end (as they just stand for the border of a barcode). How would I go about doing this?
  20. Fixed that too. The PHP drew the file with the MIME type of PNG, and I was using imagecreatefromjpg. Simply changing jpg to png solved that.
  21. Actually, I could use help on one more thing. The 'image' that I'm using here is drawn in php, and is a PHP file. It's MIME type is a .png, but when I enter the .php file as the image obviously it doesn't work. How can I work around this? ???
  22. Never mind, I just put the return vars in the wrong spot. This does it: <?php function getpixels($pic){ $image = imagecreatefromjpeg($pic); list($width, $height) = getimagesize($pic); $height = $height/2; $vars = array(); for ($i=0; $i<=$width; $i++){ $color = imagecolorat($image, $i, $height); array_push($vars, $color); } return $vars; } $pixls = getpixels("world.jpg"); foreach($pixls as $pixl){ echo "$pixl<br />"; } ?>
  23. <?php function getpixels($pic){ $image = imagecreatefromjpeg($pic); list($width, $height) = getimagesize($pic); $height = $height/2; $vars = array(); for ($i=0; $i<=$width; $i++){ $color = imagecolorat($image, $i, $height); array_push($vars, $color); return $vars; } } $pixls = getpixels("world.jpg"); foreach($pixls as $pixl){ echo "$pixl<br />"; } ?> What I was trying to do here was to get the hex color code of each pixel across an image, but the code returns numbers like this: "162486" which clearly isn't any hex color codes. How can I modify this to return the hex color value of each pixel?
  24. You can also do something like this: <?php echo <<<HERE <b><h3><center>Chislam's Chat Box</center></h3></b> <iframe src="chat.txt" width="700" height="250"></iframe> <form method="post" name="form">Nickname: <input type="text' name="nickname" value="$nickname"><br> Message: <input type="text" name="message"><input type="submit" value="Submit"> </form> <a href="chat.php">Refresh</a> HERE; ?> Notice the echo <<<HERE and the HERE; at the bottom; inbetween that, you can print pure HTML, and you don't need to escape any quotes or anything. That's what I use to echo quotes.
×
×
  • 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.