Jump to content

princeofpersia

Members
  • Posts

    208
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

princeofpersia's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  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
×
×
  • 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.