Jump to content

princeofpersia

Members
  • Posts

    208
  • Joined

  • Last visited

    Never

Everything posted by princeofpersia

  1. I have even tried it with a static picture but still same result
  2. Hi guys, I have a php crop issue, I am using Jcrop (JQUERY plugin) to allow users crop their user profile picture jquery doesnt have an issue (is easy to select) but when processing image crop in PHP, image crop doesnt work and all i get is the screenshot attached (of the page processing both upload and crop PHP code), so this all happens in same page. Could you please let me know what im doing wrong? My GD is enabled as below GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.2.1 GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled XPM Support enabled XBM Support enabled and this is my code <?php include_once ("../../../includes/functions.inc"); include_once ("../../../includes/mainheader.php"); authenticate(); ?> <script language="Javascript"> $(function(){ $('#cropbox').Jcrop({ aspectRatio: 1, onSelect: updateCoords }); }); function updateCoords(c) { $('#x').val(c.x); $('#y').val(c.y); $('#w').val(c.w); $('#h').val(c.h); }; function checkCoords() { if (parseInt($('#w').val())) return true; alert('Please select a crop region then press submit.'); return false; }; </script> <div class='alert alert-block'> <a class='close' data-dismiss='alert' href='#'>×</a> <h4 class='alert-heading'>Important!</h4> We only accept Gif, JPG, JPEG, BMP and PNG file formats. Please make sure your picture file size doesn't exceed more than 300KB. </div> <?php define ("MAX_SIZE",409600); $path = "../../static/images/profile-pic/"; $valid_formats = array("jpg", "png", "gif", "bmp"); if(isset($_POST['submit'])) { $name = $_FILES['photoimg']['name']; $size = $_FILES['photoimg']['size']; if ($_FILES["photoimg"]["name"] > MAX_SIZE) { echo"<div class='alert alert-error'> <a class='close' data-dismiss='alert' href='#'>×</a> <h4 class='alert-heading'>File Size Exceeded!</h4> </div>"; } else if(strlen($name)) { list($txt, $ext) = explode(".", $name); if(in_array($ext,$valid_formats)) { $actual_image_name =$_SESSION['account_ref'].time().substr($txt, 5).".".$ext; $tmp = $_FILES['photoimg']['tmp_name']; if(move_uploaded_file($tmp, $path.$actual_image_name)) { $_SESSION['image_name']=$actual_image_name; $insert=mysql_query("INSERT INTO profile_pic (profile_pic,account_no,img_session) VALUES ('$actual_image_name', '".$_SESSION['account_ref']."','".$_SESSION['image_name']."')"); } else echo"<div class='alert alert-error'> <a class='close' data-dismiss='alert' href='#'>×</a> <h4 class='alert-heading'>There is an error!</h4> </div>"; } else echo"<div class='alert alert-error'> <a class='close' data-dismiss='alert' href='#'>×</a> <h4 class='alert-heading'>Invalid File Format!</h4> </div>"; } else echo"<div class='alert alert-error'> <a class='close' data-dismiss='alert' href='#'>×</a> <h4 class='alert-heading'>No Photo?</h4> </div>"; } ?> <div class="single-page-header"> <h1 class="pages-header">Upload Your Profile Picture</h1></div> <div class="single-page-content"> <div class="span8 activate-login"> <?php $select=mysql_query("SELECT * FROM profile_pic WHERE img_session='".$_SESSION['image_name']."'"); while($row=mysql_fetch_array($select)) { $actual_image_name=$row['profile_pic']; } ?> <div class="image-decorator"> <img alt="profile-pic" height="360" id="cropbox" src="<?php echo"../../static/images/profile-pic/$actual_image_name"; ?>" width="480" /> </div> <div> <form id='' method='post' enctype='multipart/form-data' class='form-horizontal'> <input type='file' name='photoimg' id='photoimg' /> <input type='hidden' name='image_name' id='image_name' value='<?php echo($actual_image_name)?>' /> <button type='submit' class='btn btn-primary' name='submit'>Upload</button> </form> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['crop'])) { $targ_w = $targ_h = 150; $jpeg_quality = 90; $src = '../../static/images/profile-pic/$actual_image_name'; $img_r = imagecreatefromjpeg($src); $dst_r = imagecreatetruecolor($targ_w,$targ_h); imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'], $targ_w,$targ_h,$_POST['w'],$_POST['h']); header('Content-type: image/jpeg'); imagejpeg($dst_r,$output_filename,$jpeg_quality); exit; } ?> <!-- This is the form that our event handler fills --> <form action="profile-picture.php" method="post" onsubmit="return checkCoords();"> <input type="hidden" id="x" name="x" /> <input type="hidden" id="y" name="y" /> <input type="hidden" id="w" name="w" /> <input type="hidden" id="h" name="h" /> <input type="submit" value="Crop Image" name="crop"/> </form> <?php include_once ("../../../includes/footer.php"); ?> Thanks in advance
  3. try this, <?php session_start(); $email = $_SESSION['email']; $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); if(!empty($email) && isset($email) &&!empty($password) && isset($password)) { $password = md5($password); require "includes/init/db_con.php"; $query = mysql_query("SELECT * FROM users WHERE email = '$email'"); $numrows = mysql_num_rows($query); if($numrows != 0) { $row = mysql_fetch_assoc($query); $dbemail = $row ['email']; $dbpassword = $row ['password']; if($dbemail === $email && $dbpassword === $password) { $_SESSION['email'] = $dbemail; header("location: http://localhost/control/home.php"); } else { // Login failed because email or password did not match header('Location: login.php?login_failed'); } } else { // Log in failed because the sessions email did not match a user record? #header('Location: login.php?login_failed'); } } require "includes/overall/header.php"; if($_GET['login_failed']){ echo "Login Box will appear with messages"; } require "includes/overall/footer.php"; The problem was with md5 conversion, this should work Password should be $password = md5($password); and not $password = md5("$password"); I couldnt see anything else wrong, if problem still exist change if($dbemail === $email && $dbpassword === $password) to if($dbemail == $email && $dbpassword == $password)
  4. my mistake didnt get the difference woth smokers and smoker, its working now, thanks alot for ur help
  5. This is what i get Warning: implode() [function.implode]: Invalid arguments passed in ....
  6. Hi guys, I have a form with a multiselect option as below <select multiple="multiple" id="smoker" name="smoker[]"> <option value="" selected="selected">Please select</option> <option value="No" >No</option> <option value="Occasionally" >Occasionally</option> <option value="Often" >Often</option> <option value="Open to All" >Open to All</option> </select> and need to pass this info into mysql insert, but before that I need them to be seperated by coma, i have the code below but keep getting errors if ($_SERVER['REQUEST_METHOD'] == 'POST') { $smoker=stripslashes($_POST['smoker']); $smoker_db=implode(", ",$smoker); } this is the error i get Could you please help me with this? Many thanks in advance
  7. well its a ipn so i cant echo anything out on that page. how do i get php report on? thanks for your help so far dude
  8. yeah i got what you mean now, I can send email, I tested it on a test page, its just this IPN page that wont send anything, so it should be my code.
  9. No, its online on a Apache server, why? should i ask hosting company?
  10. Hi guys I have IPN setup for my online shop which is working fine but when payment is confirmed, my shop should send a link confirming purchase along with list of items, so I have added that to my IPN, there is an issue, it owuldnt send the email, I have checked every table/column name and they are correct, IPN works because I receive paypal confirmation email and updates database, so something should be wrong with they way I have written the code to send this email. Please find the code below, I have deleted some un-necessary info: <? include ('includes/db.php'); // PHP 4.1 // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $order_id = mysql_real_escape_string((int)$_POST['custom']); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { if ($payment_status=='Completed') { $txn_check=mysql_query("SELECT txn_id FROM orders WHERE txn_id='$txn_id'"); if (mysql_num_rows($txn_check)!=1) { if($receiver_email=='me@mydomain.com'){ ////////// $get=mysql_query("SELECT amount FROM orders WHERE amount='$payment_amount'"); while ($get_row=mysql_fetch_array($get)) { $amount=$get_row['amount']; } if($amount==$payment_amount && $payment_currency=='GBP') { $update=mysql_query("UPDATE orders SET confirmed='1', txn_id='$txn_id' WHERE order_ref='$order_id'"); $select=mysql_query("SELECT * FROM ordered_product WHERE order_ref='$order_id'"); while($row=mysql_fetch_array($select)) { $product_number=$row['product_ref']; $quantity_ordered=$row['quantity_ordered']; $update=mysql_query("UPDATE products SET instock=instock-1 WHERE product_ref='$product_number'"); } $select=mysql_query("SELECT * FROM orders WHERE order_ref='order_id' AND confirmed='1'"); while ($row=mysql_fetch_array($select)) { $order_number=$row['order_ref']; $name=$row['user_name']; $email=$row['user_email']; $address1=$row['address_1']; $address2=$row['address_2']; $address3=$row['address_3']; $city=$row['city']; $postcode=$row['postcode']; $country=$row['country']; $amount=$row['txn_id']; $date=$row['order_date']; } $select=mysql_query("SELECT * FROM ordered_product WHERE order_ref='$order_id'"); while($get_row=mysql_fetch_array($select)) { $product_ref=$get_row['product_ref']; $quantity=$get_row['quantity_ordered']; } $select=mysql_query("SELECT * FROM products WHERE product_ref='$product_ref'"); while($get_row=mysql_fetch_array($select)) { $product_name=$get_row['product_name']; $product_price=$get_row['price']; echo "<table width='439' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='219'>$product_name</td> <td width='120'>$quantity</td> <td width='98'>£$product_price</td> </tr> </table>"; } ///////// $headers=array( 'From:me@mydomain.com', 'Content-Type:text/html' ); $body="<table width='492' border='0' cellspacing='0' cellpadding='0' style='font-family:Verdana, Geneva, sans-serif; font-size:12px; color:#333;'> <tr> <td width='492' height='374' valign='top'><table width='497' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='497' height='97'><img src='../images/logo.png'/></td> </tr> <tr> <td>Thank you for ordering. Your order should arrive in the next 2-3 days.</td> </tr> <tr> <td height='48'><strong>ORDER NUMBER:</strong> $order_number</td> </tr> <tr> <td height='48'><p><strong>DELIVERY ADDRESS: </strong></p> <p>$address1 <br/> $address2 <br/> $address3 <br/> $city <br/> $postcode <br/> $country</p> <p> </p></td> </tr> <tr> <td height='48'><p><strong>YOUR ORDER:</strong></p> <table width='439' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='219'><strong>Item</strong></td> <td width='120'><strong>Quantity</strong></td> <td width='98'><strong>Price</strong></td> </tr> </table><br/> <table width='439' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='219'>$product_name</td> <td width='120'>$quantity</td> <td width='98'>£$product_price</td> </tr> </table> <p> </p></td> </tr> <tr> <td height='48'><p><strong>Sub Total:</strong> £amount<br/> </p></td> </tr> </table></td> </tr> <tr> <td height='374' valign='top'><strong>N.B Any sales items are non-returnable</strong></td> </tr> </table> "; $subject = "ORDER CONFIRMATION - "; mail($to, $subject, $body, implode("\r\n",$headers)); } //////// } } } } else if (strcmp ($res, "INVALID") == 0) { header('Location: payment-error.php'); } } fclose ($fp); } ?> Thank you all in advance
  11. I just changed it to int but still messed up
  12. It just doesn't the same code works on another website, I check mysql versions, they are same. It is a varchar
  13. $select=mysql_query("SELECT * FROM products ORDER BY order_id"); and then while($row=mysql_fetch_assoc($select)) {}
  14. Hi Guys I have a product page in mysql as below: id itemnumber order_id 1 348939012 2 2 535432454 1 3 543253424 4 4 987698769 3 I need to order this in my PHP mysql_fetch_assoc by order id. What I mean is I need to list them by order_id: 1,2,3,4 I have used ORDER BY order_id but still it wont work, any ideas?
  15. Hi guys, Im trying to insert a session into a html select <option> but never done it before, can you help me to see how? I have a code here but there is a syntax error if($_SESSION['name']){ echo "<option value=$_SESSION['name']>$_SESSION['name']</option>"; } Thanks for your help
  16. well done, you are great. it worked fine. Thank you so much
  17. Hi guys, im working on a login page and keep getting an error, I have checked my db.php details and they are correct and also end up calling my hosting company to check details and all was right. I have included the link to db.php and also copied and pasted it in the same page but still getting the same result. Table name and field names are correct. this is the error i get and i appreciate if you help me to see what im doing wrong. Thanks in advance. Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #5' at line 1 Resource id #5 if (isset($_POST['login'])) { $email= htmlentities(trim($_POST['email'])); $password= htmlentities(trim($_POST['password'])); if (!$email || !$password) echo"<div class='msgerror'>Please enter both Username and Password</div>"; else { $selectemail=sprintf("SELECT * FROM users WHERE myemail='%s'",mysql_real_escape_string($email)); $myselect=mysql_query($selectemail); $result = MYSQL_QUERY($myselect) or die('Query failed: ' . mysql_error() . "<br />\n$myselect"); if (mysql_num_rows($myselect)==0) { echo"<div class='msgerror'>This email address does not exist in our database</div>"; } else { $password=md5($password); while ($get_row=mysql_fetch_array($myselect)) { $myemail=$get_row['myemail']; $mypassword=$get_row['mypassword']; } if($password!=$mypassword) echo"<div class='msgerror'>Wrong username/password. Please try again</div>"; else { $_SESSION['email']=$myemail; //header('Location: ../admin/admin.php'); }}}} ?>
  18. Thats what i though but what if a users doesn't complete and don't close the browser?
  19. Hi guys, I was wondering if we have table of seats in a cinema (which makes the quantity to 1) and two users are booking the same seat at the same time on our application. How can we prevent that? I though if we create a session or even update that seat row and then if user doesn't finish the booking/or leave the browser on fora while in 10-15 minutes, that session still remains on. I'm sure we can expire that session how can we prevent both users have the same session and if one doesn't complete the purchase for any reason then how session can automatically update the database after that 15 minutes? Thanks in advance.
  20. Hi guys, I have page where it echos out the image url from mysql in a MAMP Server, however when i echo the image url out it seems to be fine but as soon as i put in a img scr it wont show the image but it shows the container. I have the code here <div id="maincontentholderbottom"> <div id="maincontentholderbottom-index-left"> <div id="news-container"><ul> <?php $select=mysql_query("SELECT * FROM news"); while($get_news=mysql_fetch_array($select)){ $newsid=$get_news['id']; $title=$get_news['title']; $text=$get_news['text']; $newsdate=$get_news['date']; $newstime=$get_news['time']; $imagelink=$get_news['newsimagelink']; $newstext=substr($text, 0, 420); echo"<li><div id='title'>$title</div><div id='newsblock'>$newstext... <a href='http://localhost/mycomputer/create/news/index.php?id=$newsid'>Read More</a></div> <div id='newsimage'><img src='$imagelink' width='150' height='70'/></div> </li>"; } ?> </ul> </div> </div> </div> Do u know why is it like this? I appreciate your help in advance. Thanks!
  21. I get the point now, sorted thanks very much for your time mate
  22. from post, in my form, i need to register this session from there,
×
×
  • 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.