Jump to content

oMIKEo

Members
  • Posts

    19
  • Joined

  • Last visited

About oMIKEo

  • Birthday 02/07/1984

Contact Methods

  • MSN
    woodward_michael@hotmail.com
  • Website URL
    http://

Profile Information

  • Gender
    Not Telling
  • Location
    Leeds, UK

oMIKEo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. All I get is the following even after refreshing a bunch of times: product1 = 1 Ok, had a change of plan and uploaded the code to some other hosting and its working fine so I guess its a php session issue with that hosting causing the data to not actually save in the sessions. I'll contact support and see if they can figure it out for me. Thanks for your help!
  2. Even if I remove that "setup" code it doesn't change anything, I can't see how it would be resetting itself. Any other ideas welcome?
  3. Hi all, I'm trying to build a simple shopping cart, there are only 8 products and I want to save the quantity value into a section for each product (product1, product2, etc). I'm having a problem where the I can't get the session value to increase by one if the same item is added to the cart again. Here is the code I have so far, am I missing something or is there a php setting that would cause this not to work. <?php session_start(); // setup if(!isset($_SESSION['product1'])) $_SESSION['product1'] = 0; if(!isset($_SESSION['product2'])) $_SESSION['product2'] = 0; if(!isset($_SESSION['product3'])) $_SESSION['product3'] = 0; if(!isset($_SESSION['product4'])) $_SESSION['product4'] = 0; if(!isset($_SESSION['product5'])) $_SESSION['product5'] = 0; if(!isset($_SESSION['product6'])) $_SESSION['product6'] = 0; if(!isset($_SESSION['product7'])) $_SESSION['product7'] = 0; if(!isset($_SESSION['product8'])) $_SESSION['product8'] = 0; // add product if(mysql_escape_string($_GET['add']) != '') { $addItem = mysql_escape_string($_GET['add']); $_SESSION["product$addItem"] = $_SESSION["product$addItem"] + 1; } echo "product$addItem = ".$_SESSION["product$addItem"]; ?> Thanks!
  4. That hasnt worked, that has made it so if the image is smaller it is increased to the max dimention so the image gets distorted. And still wont process images that are larger. Exact images get uploaded fine. (thanks for the attempt though) Any other ideas??
  5. Ive got this script that should take an uploaded image and resize it. The script works if the image is exactly the set max dimention or lower but not if the image is larger. Can anyone point out where i am going wrong? HERE IS THE INITIAL SCRIPT <?php if ($_FILES['photo']['name'] != "") { list($width, $height, $type, $attr) = getimagesize($_FILES['photo']['tmp_name']); do { $photo1 = randomstring(16); } while (file_exists("../i/news/" . $photo1)); $types = array(1 => 'GIF', 2 => 'JPG', 3 => 'PNG', 4 => 'SWF', 5 => 'PSD', 6 => 'BMP', 7 => 'TIFF(intel byte order)', 8 => 'TIFF(motorola byte order)', 9 => 'JPC', 10 => 'JP2', 11 => 'JPX', 12 => 'JB2', 13 => 'SWC', 14 => 'IFF', 15 => 'WBMP', 16 => 'XBM'); $photo1 = $photo1 . '.' . $types[$type]; // Automatic resize handleUploadedFile($photo1, $_FILES['photo']['tmp_name'], '../i/news/'); } ?> HERE IS THE FUNCTION <?php function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } function randomstring( $stringlength, $allowchars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ) { $output = ""; mt_srand(make_seed()); $count = strlen( $allowchars ); for( $i = 0; $i < $stringlength; $i++ ) { $output .= $allowchars[ mt_rand( 0, $count - 1 ) ]; } return $output; } function handleUploadedFile($file_name, $tmp_name, $target_path){ // $file_name = the name that the file is going to be stored as on the server. // $tmp_name = the temporary storage place of the file on the server. // $target_path = Where the file is going to be placed $no_support = false; $error = ""; $target_path = $target_path . $file_name; // PUT THE TARGET DIRECTORY AND FILE NAME TOGETHER. // CHECK IF FILE NEEDS TO BE RESIZED. $max_dimensions = 250; list($width, $height, $type, $attr) = getimagesize($tmp_name); // GET FILE INFO OF THE TEMPORARY FILE. // CHECK IF THE TYPE OF THE UPLOADED IMAGE IS SUPPORTED BY THE SERVER. // IF SO... CREATE AN IMAGE FROM THE TEMPORARY FILE. if($type==1){ if(function_exists("imagecreatefromgif") == false OR function_exists("imagegif") == false){ $no_support = true; $error="No support for this GIF image."; } else{ $src_image = imagecreatefromgif($tmp_name); } } else if($type==2){ if(function_exists("imagecreatefromjpeg") == false OR function_exists("imagejpeg") == false){ $no_support = true; $error="No support for this JPEG image."; } else{ $src_image = imagecreatefromjpeg($tmp_name); } } else if($type==3){ if(function_exists("imagecreatefrompng") == false OR function_exists("imagepng") == false){ $no_support = true; $error="No support for this PNG image."; } else{ $src_image = imagecreatefrompng($tmp_name); } } else{ $error="This image-type is not supported."; } // CHECK IF THE IMAGE NEED TO BE RESIZED. if($width <= $max_dimensions AND $height <= $max_dimensions){ if($no_support != true){ // IF SUPPORTED.. UPLOAD IMAGE. // ... UPLOAD FILE. move_uploaded_file($tmp_name, $target_path); } if(isset($src_image) == true){imagedestroy($src_image);} return "right_size"; } // IF AN ERROR OCCURED.. END THE FUNCTION BY RETURING THE ERROR. if($error != ""){ imagedestroy($src_image); return $error; } // DETERMINE THE NEW IMAGE DIMENSIONS. if($width > $height){ $new_width=$max_dimensions; // MAX WIDTH OF THE IMAGE. $new_height=($height/$width)*$new_width; // CALCULATE THE APPROPRIATE HEIGHT OF THE IMAGE. } else{ $new_height=$max_dimensions; // MAX HEIGHT OF THE IMAGE. $new_width=($width/$height)*$new_height; // CALCULATE THE APPROPRIATE WIDTH OF THE IMAGE. } // RESIZE THE IMAGE. if (function_exists("imagecopyresampled") && function_exists("imagecreatetruecolor")){ $new_image=imagecreatetruecolor($new_width,$new_height); imagecopyresampled($new_image,$src_image,0,0,0,0,$new_width,$new_height,$width,$height); } else { // IF imagecopyresample DOESNT EXIST USE imecopyresized WHICH GIVES LOWER QUALITY. $new_image=imagecreate($new_width,$new_height); imagecopyresized($new_image,$src_image,0,0,0,0,$new_width,$new_height,$width,$height); } // SAVE THE FILE TO THE SERVER. switch ($type){ case 1: // TYPE IS gif imagegif($new_image,$target_path,100); break; case 2: // TYPE IS jpg imagejpeg($new_image,$target_path,100); break; case 3: // TYPE IS png imagepng($new_image,$target_path,100); break; } // DELETE THE IMAGES FROM THE TEMPORARY STORAGE PLACE. imagedestroy($src_image); imagedestroy($new_image); return ""; } ?> Thanks, Mike
  6. Thanks guys, Ive tried using just: setcookie("UN", $username, time()+3600); but that didnt help (if thats what you meant) The thing is ive used this exact script on a number of other hosting providers and its worked fine which is why im so confused and really need some help.... thanks
  7. Hi, Can anyone tell me why this code isnt working, the login script creates a cookie, then redirects you to a profile page, that page first checks to see if the cookie exists otherwise kicks you to a login page. I added print_r($_COOKIE); onto the profile page to see what cookies are being passed to that page, it comes back with none :S [code]<?php include "config.php"; if( (!$username) or (!$password) ) { header("Location:$HTTP_REFERER"); exit(); } $conn=@mysql_connect("$db_host","$db_username","$db_password") or die("Could not connect"); $rs = @mysql_select_db($db_main,$conn) or die("Could not select database"); $sql="select * from bn_profile where band_email=\"$username\" and password=\"$password\""; $rs=mysql_query($sql,$conn) or die("Could not execute query" . mysql_error()); $num12 = mysql_num_rows($rs); if($num12!=0) { setcookie("UN", $username, time()+3600, "/", ".breakingtuneshosting.com", 0); header("Location:profile.php"); exit(); } else { header("Location:$HTTP_REFERER"); exit(); } ?>[/code] Also if i echo $num12; i get a value of 1 so it should be creating the cookie. Any ideas?
  8. Hi, Ive got all my validation complete but would like to know how to make it so that when i click the submit button it runs through the php validation and then submits the form to register1.php (where the values are stored in the DB and more info is collected? Here is the code:[code]<?php if($_POST['sent'] == "Y") { $password =  stripslashes($_POST['password']); $band_email = stripslashes($_POST['band_email']); $personal_email = stripslashes($_POST['personal_email']); $act_type = stripslashes($_POST['act_type']); $genre = stripslashes($_POST['genre']); $act_name = stripslashes($_POST['act_name']); $fullname = stripslashes($_POST['fullname']); $mobilenumber = stripslashes($_POST['mobilenumber']); $county = stripslashes( $_POST['county']); $conn=mysql_connect("$db_host","$db_username","$db_password") or die("Err:Conn"); $rs = mysql_select_db("$db_main",$conn) or die("Err:Db"); $sql="select * from bn_profile where band_email = \"$band_email\""; $rs=mysql_query($sql,$conn) or die("Could not execute query: ".mysql_error()); $bandemailnum = mysql_num_rows($rs); if($act_type == "0") $e1 = 'Please select an Act Type'; elseif($genre == "0" && $act_type == "1") $e2 = 'Please select a Genre'; elseif($act_name == "") $e3 = 'Please enter your Act Name'; elseif($fullname == "") $e4 = 'Please enter your Full Name'; elseif($mobilenumber == "") $e5 = 'Please enter your Telephone Number'; elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $personal_email)) $e6 = 'Please enter a valid Email Address'; elseif($county == "0") $e7 = 'Please select a County'; elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $band_email)) $e8 = 'This is not a valid Email Address'; elseif ($bandemailnum > 0) $e8 = '<br />This Email Address has already been used.<br />Please enter a new address or have you <a href="password.php">Forgotten your Password</a>'; elseif($_POST['band_email_check'] != $band_email) $e9 = 'Band Email Addresses dont match'; elseif (strlen($password) < 5) $e10 = 'Please ensure your Password is 5 or more characters'; elseif($_POST['password_check'] != $password) $e11 = 'Passwords dont match'; else { //SUBMIT NOW! } header("Location:register1.php"); exit(); }[/code] This code is at the top of register.php and the form looks like: [code]<form action="register.php" method="post" enctype="application/x-www-form-urlencoded" name="form2"> . . . </form>[/code] At the moment when you click submit it goes to the same page, the SENT variable equals Y so it does the validation. Thanks for any help, Mike
  9. try adding $id instead of just id in the IF statement. Mike
  10. Hi, Ive created a search area to a site but its not working too good... The scripts checks a 'thetype' field and then checks a 'keywords' field. The 'thetype' can only be either Perminent or Contract (or Any) The 'keywords' can be anything and are stored in the database seporated by commas (e.g. key1, key2, key3) It wont let you seach for multiple keywords at once, how can i improve this script to its not a picky but still relevant when finding results? [code]<?php $conn=mysql_connect("$db_host","$db_username","$db_password") or die("Err:Conn"); $rs = mysql_select_db("$db_main",$conn) or die("Err:Db"); $thetype = $_POST['types']; $keywords = $_POST['keywords']; if($thetype == "Any") { if($keywords == ""); $sql="select * from rec_jobs"; if($keywords != ""); $sql="select * from rec_jobs where keywords LIKE '%$keywords%'"; } if($thetype != "Any") { if($keywords == ""); $sql="select * from rec_jobs where `type` = '$thetype'"; if($keywords != ""); $sql="select * from rec_jobs where `type` = '$thetype' AND keywords LIKE '%$keywords%'"; } $rs=mysql_query($sql,$conn) or die("Could not execute query: ".mysql_error());     $thenum = mysql_num_rows($rs); if ($thenum != 0) echo '<table style="width:700px;"> <tr> <td width="33%" height="32px"><strong>Job Title</strong></td> <td width="33%" height="32px"><strong>Location</strong></td> <td width="33%" height="32px"><strong>Salary</strong></td> </tr>'; else echo '<table style="width:100%"> <tr> <td></td> </tr>'; while($row=mysql_fetch_array($rs)) { $job_id = ''.$row[id].''; $title = ''.$row[title].''; $description = ''.$row[description].''; $type = ''.$row[type].''; $location = ''.$row[location].''; $salary = ''.$row[salary].''; $featured = ''.$row[featured].''; echo '<tr> <td width="33%" height="32px"><a href=job_details.php?id='.$job_id.'>'.$title.'</a></td> <td width="33%" height="32px">'.$location.'</td> <td width="33%" height="32px">'.$salary.'</td>   </tr>'; } echo '</table>'; if ($thenum == 0) echo '<strong>No jobs found</strong><br><br> <a href="job_seekers.php">Try Again</a>'; else echo '<br><br><a href="job_seekers.php"><strong>New Search</strong></a>'; ?>[/code] Thanks, Mike
  11. Ive managed to get past the first problem and can log into the system. This is a message board approval section and there are a delete and approve buttons for each message posted. they dont work though now they go to the correct link but it doesnt delete or approve anything. Can anyone help:[code]<?php if (!$_COOKIE[UN]) {    header("Location:login.php"); } include("top.php"); if($delete != "") { // DO DELETE     $conn =mysql_connect("$db_host","$db_username","$db_password") or die("Err:Conn");     $rs=mysql_select_db($db_main, $conn) or die("Err: Db");     $sql = "delete from hsm_messages where id = '$delete'";     $result = mysql_query($sql,$conn) or die("Err:Query"); } if($approve != "") { // DO APPROVE     $conn = mysql_connect("$db_host","$db_username","$db_password") or die("Err:Conn");     $rs= mysql_select_db($db_main, $conn) or die("Err: Db");     $title = "Y";         mysql_query("UPDATE hsm_messages SET approved = '" . $title . "' where id = '$approve'") or die(mysql_error()); } ?>[/code]thanks for any advice.
  12. thanks, thats 1 step closer.... It redirects fine but i its not getting past the first part of the code so i think its not detecting any value for the username and password. Any ideas? Thanks
  13. using the the code below i get this error:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in D:\inetpub\vhosts\***\httpdocs\pupils\authenticate.php on line 4[/quote][code]<?php include "config.php"; if( (!$_POST['username']) or (!$_POST['password']) ) { header("Location:$_SERVER['http_referer']"); exit(); } $conn=@mysql_connect("$db_host","$db_username","$db_password") or die("Could not connect"); $rs = @mysql_select_db($db_main,$conn) or die("Could not select database"); $sql="select * from hsm_users where username=\"$username\" and password=\"$password\""; $rs=mysql_query($sql,$conn) or die("Could not execute query"); $num = mysql_num_rows($rs); if($num !=0) { setcookie("UN",$username); header("Location:approver.php"); exit(); } else { header("Location:$_SERVER['http_referer']"); exit(); } ?>[/code]
  14. In IE i get a "The page cannot be displayed" error and in FF i get an "Object Moved" error. I think it doesnt like the redirects but im not sure. Any ideas? Thanks, Mike
  15. hi, ive coded a page that works fine on my hosting but not on the clients, i believe its because register globals is set to off so i need to change my code so it works with that off... I dont know how though. Here is the code:[code]<?php include "config.php"; if( (!$username) or (!$password) ) { header("Location:$HTTP_REFERER"); exit(); } $conn=@mysql_connect("$db_host","$db_username","$db_password") or die("Could not connect"); $rs = @mysql_select_db($db_main,$conn) or die("Could not select database"); $sql="select * from hsm_users where username=\"$username\" and password=\"$password\""; $rs=mysql_query($sql,$conn) or die("Could not execute query"); $num = mysql_num_rows($rs); if($num !=0) { setcookie("UN",$username); header("Location:approver.php"); exit(); } else { header("Location:$HTTP_REFERER"); exit(); } ?>[/code]Thanks for any help. Mike
×
×
  • 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.