Jump to content

guymclaren

Members
  • Posts

    48
  • Joined

  • Last visited

    Never

Everything posted by guymclaren

  1. Since when has setting cookies been changing header information?
  2. The cookies are not being set period. It gives me the successfully logged in message, but no cookies are available. the rest of the script works as it should.
  3. Here is the full code in context <?php include ("../navigation/header.php"); $ident = "0"; $basket = $_REQUEST["id"]; $name = $_REQUEST["uname"]; $pass1 = $_REQUEST["pass1"]; include ("../navigation/constants.php"); ?> <div id="contenti"> <div id="iwrap1"> <div class="post-title"> <h2> Catalogue - Log In</h2> </div> <div id="post-entry"> <? //Check if form has been filled in If ($name != NULL){ If ($pass != NULL) { //check database $sqlq="SELECT * FROM Clcontacts INNER JOIN Clients ON Clcontacts.Company=Clients.id WHERE Clcontacts.email = '".$name."' AND Clcontacts.password = '".$pass1."'"; $objRS = mysql_query($sqlq); $rows = mysql_num_rows($objRS); if ($rows == 0) { echo "<h2>Log in failed</h2>The username or password is incorrect, please try again"; ?> <h2>Log In</h2> <form action="login.php" method="GET"> <table> <tr><td>user name: (email address)</td><td><input type="text" name="uname" /></td></tr> <tr><td>Password:</td><td><input type="password" name="pass1" /></td></tr> <tr><td></td><td><input type="submit" value="Submit" /></td></tr></table> </form> <? } else { $email = mysql_result($objRS, 0,"Clcontacts.email"); $name1 = mysql_result($objRS, 0,"Clcontacts.name"); $uid1 = mysql_result($objRS, 0,"Clcontacts.id"); $coid1 = mysql_result($objRS, 0,"Clients.id"); $status1 = mysql_result($objRS, 0,"Clcontacts.status"); echo $email." ".$uid1." ".$coid1." ".$status1."<br />"; $value = "myfuckingtime"; setcookie("TestCookie",$value, time()+3600*24*352); setcookie("user", $name1, time()+14400); setcookie("userid", $uid1, time()+14400); setcookie("coid", $coid1, time()+14400); setcookie("login", "yes", time()+14400); setcookie("status", $status1, time()+14400); echo "Welcome ".$name1.", You have succesfully logged in.<br /><br />"; $loggedin = $_COOKIE["login"]; echo $loggedin; } } } else { ?> <h2>Log In</h2> <form action="login.php" method="GET"> <table> <tr><td>user name: (email address)</td><td><input type="text" name="uname" /></td></tr> <tr><td>Password:</td><td><input type="password" name="pass1" /></td></tr> <tr><td></td><td><input type="submit" value="Submit" /></td></tr></table> </form> <? } ?> </div> <div class="post-info"></div> </div>
  4. The code below is the only part of my script failing and I have no clue why. I even tried setting the TestCookie for 352 days. What boggles my mind is that this code used to work and is now failing. Has something changed? $value = "wtf"; setcookie("TestCookie",$value, time()+3600*24); setcookie("user", $name1, time()+14400); setcookie("userid", $uid1, time()+14400); setcookie("coid", $coid1, time()+14400); setcookie("login", "yes", time()+14400); setcookie("status", $status1, time()+14400);
  5. so simple and elegant, Thank you. I'll try that
  6. Before anyone has a go at me, I have Googled, tried to create an array from the result and have failed miserably. In essence what I have is a result from a sql query multiplied with another giving me a row total. while row exists $var = $result1 * $result2 Now I want to total up $var1 which could be a single entry or a list of entries. I have tried to create an array for($i = 0; $i < count($var); $i++){ echo $var[$i].","; } Get no result, except , $val1 = array($var[$i]); echo $val1; No result PLease help, my brain is not co-operating today.
  7. script OK as long as small files are used. any oversize file will fail, despite changing max file size.
  8. $newid = 9; ?> <html> <head> <title>Used Cars : Add Stock</title> <?php if ($_SERVER['REQUEST_METHOD'] == "POST") { $uploaddir = "../usedcars/images"; $imgfile = ($_FILES['imgfile']['tmp_name']); $imgfile_name = ($_FILES['imgfile']['name']); $imgfile1 = ($_FILES['imgfile1']['tmp_name']); $imgfile_name1 = ($_FILES['imgfile1']['name']); $imgfile2 = ($_FILES['imgfile2']['tmp_name']); $imgfile_name2 = ($_FILES['imgfile2']['name']); $imgfile3 = ($_FILES['imgfile3']['tmp_name']); $imgfile_name3 = ($_FILES['imgfile3']['name']); $imgfile4 = ($_FILES['imgfile4']['tmp_name']); $imgfile_name4 = ($_FILES['imgfile4']['name']); $pext = getFileExtension($imgfile_name); $pext = strtolower($pext); if (($pext != "jpg")) { print "<h1>ERROR</h1>Image Extension Unknown.<br>"; print "<p>Please upload only a JPEG image with the extension .jpg or .jpeg ONLY<br><br>"; print "The file you uploaded had the following extension: $pext</p>\n"; unlink($imgfile); exit(); } $pext1 = getFileExtension($imgfile_name1); $pext1 = strtolower($pext1); if (($pext1 != "jpg")) { print "<h1>ERROR</h1>Image Extension Unknown.<br>"; print "<p>Please upload only a JPEG image with the extension .jpg or .jpeg ONLY<br><br>"; print "The file you uploaded had the following extension: $pext1</p>\n"; unlink($imgfile1); exit(); } $pext2 = getFileExtension($imgfile_name2); $pext2 = strtolower($pext2); if (($pext2 != "jpg")) { print "<h1>ERROR</h1>Image Extension Unknown.<br>"; print "<p>Please upload only a JPEG image with the extension .jpg or .jpeg ONLY<br><br>"; print "The file you uploaded had the following extension: $pext2</p>\n"; unlink($imgfile2); exit(); } $pext3 = getFileExtension($imgfile_name3); $pext3 = strtolower($pext3); if (($pext3 != "jpg")) { print "<h1>ERROR</h1>Image Extension Unknown.<br>"; print "<p>Please upload only a JPEG image with the extension .jpg or .jpeg ONLY<br><br>"; print "The file you uploaded had the following extension: $pext3</p>\n"; unlink($imgfile3); exit(); } $pext4 = getFileExtension($imgfile_name4); $pext4 = strtolower($pext4); if (($pext4 != "jpg")) { print "<h1>ERROR</h1>Image Extension Unknown.<br>"; print "<p>Please upload only a JPEG image with the extension .jpg or .jpeg ONLY<br><br>"; print "The file you uploaded had the following extension: $pext4</p>\n"; unlink($imgfile4); exit(); } $imgsize = GetImageSize($imgfile); $imgsize1 = GetImageSize($imgfile1); $imgsize2 = GetImageSize($imgfile2); $imgsize3 = GetImageSize($imgfile3); $imgsize4 = GetImageSize($imgfile4); /*== check size 0=width, 1=height ==*/ if (($imgsize[0] > 235) || ($imgsize[1] > 176)) if (($imgsize1[0] > 547) || ($imgsize1[1] > 366)) if (($imgsize2[0] > 182) || ($imgsize2[1] > 122)) if (($imgsize3[0] > 182) || ($imgsize3[1] > 122)) if (($imgsize4[0] > 182) || ($imgsize4[1] > 122)) { $tmpimg = tempnam("/tmp", "MKUP"); $tmpimg1 = tempnam("/tmp", "MKUP"); $tmpimg2 = tempnam("/tmp", "MKUP"); $tmpimg3 = tempnam("/tmp", "MKUP"); $tmpimg4 = tempnam("/tmp", "MKUP"); system("djpeg $imgfile >$tmpimg"); system("djpeg $imgfile1 >$tmpimg1"); system("djpeg $imgfile2 >$tmpimg2"); system("djpeg $imgfile3 >$tmpimg3"); system("djpeg $imgfile4 >$tmpimg4"); system("pnmscale -xy 235 176 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile"); system("pnmscale -xy 547 366 $tmpimg1 | cjpeg -smoo 10 -qual 50 >$imgfile1"); system("pnmscale -xy 182 122 $tmpimg2 | cjpeg -smoo 10 -qual 50 >$imgfile2"); system("pnmscale -xy 182 122 $tmpimg3 | cjpeg -smoo 10 -qual 50 >$imgfile3"); system("pnmscale -xy 182 122 $tmpimg4 | cjpeg -smoo 10 -qual 50 >$imgfile4"); /*== remove temp image ==*/ unlink($tmpimg); unlink($tmpimg1); unlink($tmpimg2); unlink($tmpimg3); unlink($tmpimg4); } $final_file = str_replace(" ", "_", $imgfile_name); $final_filename = $newid.$final_file; $newfile = $uploaddir . "/$final_filename"; $final_file1 = str_replace(" ", "_", $imgfile_name1); $final_filename1 = $newid.$final_file1; $newfile1 = $uploaddir . "/$final_filename1"; $final_file2 = str_replace(" ", "_", $imgfile_name2); $final_filename2 = $newid.$final_file2; $newfile2 = $uploaddir . "/$final_filename2"; $final_file3 = str_replace(" ", "_", $imgfile_name3); $final_filename3 = $newid.$final_file3; $newfile3 = $uploaddir . "/$final_filename3"; $final_file4 = str_replace(" ", "_", $imgfile_name4); $final_filename4 = $newid.$final_file4; $newfile4 = $uploaddir . "/$final_filename4"; if (is_uploaded_file($imgfile)) { if (!copy($imgfile,"$newfile")) { print "Error Uploading File."; exit(); } } if (is_uploaded_file($imgfile1)) { if (!copy($imgfile1,"$newfile1")) { print "Error Uploading File."; exit(); } } if (is_uploaded_file($imgfile2)) { if (!copy($imgfile2,"$newfile2")) { print "Error Uploading File."; exit(); } } if (is_uploaded_file($imgfile3)) { if (!copy($imgfile3,"$newfile3")) { print "Error Uploading File."; exit(); } } if (is_uploaded_file($imgfile4)) { if (!copy($imgfile4,"$newfile4")) { print "Error Uploading File."; exit(); } } /*== delete the temporary uploaded file ==*/ unlink($imgfile); unlink($imgfile1); unlink($imgfile2); unlink($imgfile3); unlink($imgfile4); print("<img src=../usedcars/images/".$final_filename.">"); /*== DO WHATEVER ELSE YOU WANT SUCH AS INSERT DATA INTO A DATABASE ==*/ } ?> </head> <body bgcolor="#FFFFFF"> <h2>Add Used Car</h2> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="250000"> <p>Title: <input type="text" name="title" size="40" /> <p>Description: <input type="text" name="description" size="40" /> <p>Tags: <input type="text" name="tags" size="40" /> <p>Price: <input type="text" name="price" size="40" /> <p>Full details:<br /> <textarea cols="50" rows="10" name="notes"></textarea> <p>List Image: <input type="file" name="imgfile"> <p>Main Image: <input type="file" name="imgfile1"> <p>Page Image1 : <input type="file" name="imgfile2"> <p>Page Image2: <input type="file" name="imgfile3"> <p>Page Image3: <input type="file" name="imgfile4"> <br> <input type="submit" value="Add Entry"> </form> </body> </html> <?php /*== FUNCTIONS ==*/ function getFileExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } ?>
  9. Can someone have a look at this for me please. I have a problem, some people are receiving this multiple times and there are no duplicates in the database, but mostly the script times out before completeing. I expect the script to echo every 100th or so record. It does not. I have included the full script broken up into code blocks with notes. please help. <?php // Connection details MySQL server $username="xxxxx"; $password="xxxxx"; $database="xxxxxx"; $server="xxxxx"; mysql_connect($server,$username,$password); @mysql_select_db($database) or die("Unable to select database"); include ("../navigation/header.php"); ?> <div id="content"> <div id="contentleft"> <div class="post"> <div class="post-title"> <h2> Mailing List</h2> </div> <div class="post-entry"> <? $sqlm="SELECT * FROM xxxxxx WHERE sent !='6' AND subs !='9' ORDER BY id ASC" ; $objRSm = mysql_query($sqlm); $num_rows = mysql_num_rows($$objRSm); loop starts here while($row = mysql_fetch_array($objRSm, MYSQL_ASSOC)) { $pid = $row['id']; $name = $row['name']; $tomail = $row['email']; $city = $row['City']; $upd = "UPDATE maillist SET sent='6' WHERE email='".$tomail."'"; mysql_query($upd); // From email address $from = "xxxxxx"; $from_name = "xxxxxx "; // The message $subject = $name." THANK YOU" ; $message = "Hi ".$name.",\r\n" ."\r\n To unsubscribe click this link - http://xxxxxx.za/findit/unsub.php?id=".$tomail." Do not reply to this email, It was sent from an email address that does not get responded to. When you unsubscribe using the link, you will be removed from our mailing list immediately"; $message_html = "<html><body><p>Hi ".$name.",<br />" ."<a href=http://bit.ly/dgzjHA>33% off offer</a><br /><br />This message was sent from http://xxxxx.co.za, To unsubscribe click <a href=http://xxxxx.co.za/findit/unsub.php?id=".$tomail."> http://xxxxx.co.za/findit/unsub.php?id=".$tomail." </a>Do not reply to this email, It was sent from an email address that does not get responded to. When you unsubscribe using the link, you will be removed from our mailing list immediately </body>"; /***********************************************/ /* No need to modify anything down here */ /* Note that these are needed to send the mail */ /***********************************************/ // Generate text + html version $random_hash = md5(date("r", time())); $mailmessage = " --PHP-alt-".$random_hash." Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --PHP-alt-".$random_hash." Content-Type: text/html; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message_html --PHP-alt-".$random_hash."-- "; // Headers // To send HTML mail, the Content-type header must be set $headers = "From: ".$from_name." <".$from.">" . "\r\n"; $headers .= "Reply-To: ".$from_name." <".$from.">" . "\r\n"; $headers .= "Date: ".date("r") . "\r\n"; // Additional headers $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"PHP-alt-" . $random_hash . "\"\r\n"; $headers .= "Message-Id: <" . md5(uniqid(microtime())) . "@" . $_SERVER["SERVER_NAME"] . ">\r\n"; At this point I expect the echo on screen, but nothing happens and the script times out, I have to rerun the script about 4 times to do 1600 emails, How can I fix this? // Send the mail if ($pid % 100 == 0) { echo $pid." has been reached";} usleep(1200000); mail($tomail, $subject, $mailmessage, $headers); echo "The Newsletter has been sent to ".$num_rows." recipients<br />";} ?>
  10. Thanks Rajiv, just spotted that the file will be over written, so the delete is excess to requirements.
  11. IN essence I want to have a script calling the info from the database.. I have no problem thus far, next I want to take said data and write it to an xml file. no problem here either. I think I have that figured time will tell. But here is the problem , I want to append the new entries to the top and delete any older entries after. I sort of have this in mind Get data php file delete old xml file unlink write new xml file fopen fwrite I don't know if this is the most efficient way of doing this or not, so I thought I'd get some help here.
  12. OK so if I have no results, how do I change my query, you see if I say if status == Null then it gives me the true loop and adds the false loop at the end.
  13. I am trying to create an alternative if the answer is NULL, How or what am I doing wrong? 1. If ($status == 0){ 2. $sqlq="SELECT * FROM cocats INNER JOIN companies ON companies.id = cocats.co WHERE cocats.cat='".$cat." AND companies.status = '3' ORDER BY RAND() LIMIT 0,3"; 3. $objRS = mysql_query($sqlq); 4. while($row = mysql_fetch_array($objRS, MYSQL_ASSOC)) { 5. $status = $row["status"]; 6. $profile = $row['profile']; 7. } 8. If ($row == Null) { 9. $sqlq="SELECT * FROM companies WHERE status = '3' ORDER BY RAND()LIMIT 0,3";} 10. $objRS = mysql_query($sqlq); 11. while($row = mysql_fetch_array($objRS, MYSQL_ASSOC)) { 12. $status = $row["status"]; 13. $profile = $row['profile'] 14. } 15. }
  14. if ($objRS == "") { changed to $rows = mysql_num_rows($objRS); if ($rows == 0) {
  15. This code works fine if there is a result, but if there is no result from the db I get an error as below. How do I resolve this problem. If ($name != NULL){ If ($pass != NULL) { //check database $sqlq="SELECT * FROM Clcontacts INNER JOIN Clients ON Clcontacts.Company=Clients.id WHERE Clcontacts.email = '".$name."' AND Clcontacts.password = '".$pass."'"; $objRS = mysql_query($sqlq); if ($objRS == "") { echo "<h2>Log in failed</h2>The username or password is incorrect, please try again"; ?> <h2>Log In</h2> <form action="login.php" method="GET"> <table> <tr><td>user name: (email address)</td><td><input type="text" name="uname" /></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" /></td></tr> <tr><td></td><td><input type="submit" value="Submit" /></td></tr></table> </form> <? } else { $email = mysql_result($objRS, 0,"Clcontacts.email"); $name1 = mysql_result($objRS, 0,"Clcontacts.name"); $uid1 = mysql_result($objRS, 0,"Clcontacts.id"); $coid1 = mysql_result($objRS, 0,"Clients.id"); $status1 = mysql_result($objRS, 0,"Clcontacts.status"); setcookie("user",$name1, time()+14400); setcookie("userid",$uid1, time()+14400); setcookie("coid",$coid1, time()+14400); setcookie("login","yes", time()+14400); setcookie("status",$status1, time()+14400); echo "Welcome ".$name1.", You have succesfully logged in.<br /><br />"; Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 41 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 42 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 43 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 44 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 45
  16. $sqlq="SELECT * FROM Members"; $objRS = mysql_query($sqlq); $num = mysql_numrows($objRS); ?> <div id="content"> <div id="contentleft"> <h2>Lede Betaal geskiedenis</h2> <table> <? $i=0; while ($i < $num) { $email = mysql_result($objRS,"email"); $name = mysql_result($objRS,"Name"); $sname = mysql_result($objRS,"Surname"); $neename = mysql_result($objRS,"Nee"); $city = mysql_result($objRS,"City"); $reference = mysql_result($objRS,"id"); $sqlm = "SELECT * FROM fees WHERE member = '".$reference."'"; $objRSi = mysql_query($sqlm); $numi = mysql_numrows($objRSi); echo "<tr><td>".$name." ".$sname." </td><td>".$neename." </td><td>".$email." </td><td>".$city."</td></tr>"; $j=0; while ($j < $numi) { $amount = mysql_result($objRSi, "amount"); $date = mysql_result($objRSi, "Date"); echo "<tr><td></td><td></td><td align=right>".$date." </td><td align=right> ".$amount."</td></tr>"; $j++; } $i++; } ?> Gives me this result ede Betaal geskiedenis 10 10 10 10 10 1 1 I was expecting text, where have I gone wrong?
  17. NSS, I do that, occassionally when I am unsure I will ask a stupid question and get an even less satisfactory answer. Thank you to those that helped.
  18. I figured I would get guidance because ASP works so differently, I am actually rewriting something I did a while ago in ASP but for reasons of insanity now require in PHP. Thanks for the help
  19. $mail = " SELECT id FROM invite WHERE sentcode = '1' ORDER BY id ASC"; $rec = mysql_query($mail) or die(mysql_error()); $row = mysql_fetch_assoc($rec); while ($row != Null){ $email = $row['email']; $fname = $row['fname']; //send email// }
  20. Just to add $coid shows a null value despite the existence of the cookie
  21. Creating of cookie is done on numerous pages. I have tried letting the system create the cookie without adding the url, I tried the following $coid = $_COOKIE["affiliate"]; if ($coid == NULL) { $myid = $_GET['aff']; if ($myid != NULL){ setcookie("affiliate","$myid", time()+5184000,"webtech.co.za"); setcookie("affiliate","$myid", time()+5184000,"www.webtech.co.za"); } } It creates both cookies so in theory it should not matter whether they are using www or not, I also tried .webtech.co.za The problem is the following code on an order page does not read the cookie or give any results. $coid = $_COOKIE["affiliate"]; $aff = $coid; $fname = $_REQUEST['fname']; if ($fname != NULL) { I am tearing my hair out, PHP hates me, but I cannot cope with MIcrosofts bullshit ASP anymore, please help?
  22. Thank you, so in effect removing from either function should get it sent only once or should I remove it from the headers in preference?
  23. $coid = $_COOKIE["affiliate"]; if ($coid == NULL) { $myid = $_GET['aff']; if ($myid != NULL){ setcookie("affiliate","$myid"); } else { setcookie("affiliate","MCL01"); header('Location:http://webtech.co.za/order.php'); } }
  24. // From email address $from = "xxx@xxxx"; $from_name = "xxxxx"; // The message $subject = "Your ORDER needs confirming"; $message = " <html> <head> <title>Order Confirmation, webTECH.co.za</title> </head> <body> <p>Dear $fname</p> <p>You are receiving this email because you have just placed an order for a website at webTECH</p> <p>Please confirm this order by clicking the link below this.<br> <a href=\"http://webtech.co.za/confirm.php?id=$affid&pay=$pay\">www.webtech.co.za/confirm.asp?id=$affid</a></p> <p>Regards</p> <p>webTECH</p> <p>Tel 013 745 8337</p> <p>Cell 071 604 7754</p> </body> </html> "; // Headers // To send HTML mail, the Content-type header must be set $headers = "To: ".$fname."<".$email.">" . "\r\n"; $headers .= "From: ".$from_name." <".$from.">" . "\r\n"; $headers .= "Date: ".date("r") . "\r\n"; // Additional headers $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers .= "Message-Id: <".md5(uniqid(microtime()))."@".$_SERVER["SERVER_NAME"].">\r\n"; // Send the mail mail($email, $subject, $message, $headers);
×
×
  • 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.