Craig-UK
-
Posts
35 -
Joined
-
Last visited
-
Days Won
3
Posts posted by Craig-UK
-
-
I am not sure if it's relevant but I notice the @ is missing in front of "mysqli_query($dbc, $q);" in your function version.
-
As Jonathan has said.
if ($header) {
Checks whether "$header" has a valid value (i.e. not FALSE or empty), so "!$header" does the opposite.
if (!$header) {
Just like above but this time checks whether "$header" is empty or FALSE, if so do between { }. If doing this way theres usually a else clause.
- 1
-
I think that's cause you have ' in the $row... change all the $row['field5'] to $row[field5], that shall hopefully do the trick, same as the other field's
- 1
-
Assuming "$row['field5']" has no value if there's no URL then you could just simple to a "if" clause
if (($row['field5'] == "") || ($row['field5'] == "http://")) { // obviously change it to what suits you echo '<td align="left"></td>'; } else { echo '<td align="left"><a href="' . $row['field5'] . '">' . "Link2" . '</a></td>'; }
or something similar.
I haven't tested the code but you might need {} around {$row['field5']}
- 1
-
The only idea I have for this is a time limit for completing a purchase, so from when they 'add to basket' or 'purchase' they have 10 mins to finish the order, but for as long as they are still adding the 10 mins gets refreshed with each new item added.
I have never tried it but I can't see it being too hard, timestamp the basket, each additional purchase updates the time as they are still active on your site. You could give them 5-10 minutes on your site and 10-20mins with the payment processor, so once they have clicked to pay.. you could cancel out the site time-limit and start the payment time-limit. Most payment processors allow you to send additional hidden information, this could be the timestamp once the payment is completed you can cancel the time-limit.
If either time-limit is exceeded then the item becomes available again. Or you could simply set a overall 30min time limit to any basket to be completed from first addition. This is only 1 idea and I am sure others will come up with maybe a better solution.
- 1
-
To make this work you don't actually have to create folders. You can trick the URL for it to look like it's accessing a folder using .htaccess
RewriteEngine on RewriteBase / RewriteRule ^([A-Za-z0-9]+)/?$ page.php?folder=$1
I think that is all you need, but someone might need to correct it.
Simply get that page.php script to read from the database and show the required info.
If you do need to create folders then to get the value, save the folder name when creating it by either giving it a value and passing it through the script or giving a session it's value. Although these aren't the best of ways.
Hopefully I understood your question correctly as it's quite vague.
- 1
-
May I ask as to why you're querying the password field anyway? Surely if you're doing a login script you should compare their password using the same hash code that you chose in the registration form.
Also I think the reason why the last character was taken off when you queried the database is because it added a extra backslash 4th character in maybe theres a size limit exceeded.
-
Hmm I have duplicated this on my server and it seems to work. I can't work this out myself, I even tried changing the structure to try and break it
-
SELECT * FROM `users` WHERE `pass`='bb4c572b60661fe7dff6cca2fffc8c2155cb2cf85c5ce9f367f1c8df1228029d'
I feel very confused and somewhat embarrassed asking this question
Is it the fact that you are quoting the table of which you are trying to get information from?
Edit: Hmm scrap that, should work even when quoted.
Is there any chance you could screenshot the phpmyadmin of the password row, just to see if any of us can spot something that you possibly missed? Don't include any unrequired but secure information
-
You're welcome and thanks for letting everyone else know the problems with ShiftEdit IDE.
Glad you sorted it out.
-
Hi,
Your first error is
if (empty($errors()) {
should be
if (empty($errors)) {
You have also forgot to close the quotations on...
$q = "INSERT INTO users (first_name, last_name, email, pass, registration_date) VALUES ('$fn', '$ln', '$e', SHA1('$p'), NOW() );
And finally you have also forgot the semi-colon on this line...
echo '<h1>System Error</h1> <p>You could not be registered because of a system error. We are doing everything we can to resolve it<br />Please try again later</p>'
Once I corrected those mistakes the script seems to work on my server. If you have any other problems then feel free to let us know
-
You're right it must have been a filesize problem. I just assumed to upload larger bein's the field says min 200pixels
-
Hi,
I keep trying to upload a profile picture but keep getting the same "Failed to set a new photo" error.
I have tried a couples of pictures.
1. 2448 x 3264 jpg file 1,149 KB. This failed so assumed it was too big, so I made it smaller...
2. 612 x 816 jpg file, 111KB. This also fails.
I have tried it by clicking on my profile picture and using it that way, also by clicking edit my profile and using the upload profile picture that way. Both seem to fail.
Am I the only person havin the problem lately, as I assume those with profile pictures had them up before this new forum update?
Thanks
-
Hi Larry,
Your book is incredibly useful. I created a website for my staff to access pdfs of the different forms we use for an animal hospital. Occasionally, we change the forms content and will need to re-upload the pdf of it. I didn't see a way in your book to delete the pdf if it has already been uploaded. Any recommendations?
Thanks,
Sam
Depending on if you name them the same, you could run a function to see if the file exists. If it does exists then to delete (unlink()) then rename the new uploaded file as the same filename.
If the file is named differently then there really is no other way, unless you create a "replace" button next to each pdf or a tick option, then it replaces that using the same unlink() and file upload system.
If I was you I'd let the file upload, check existance (if using first option), unlink the old, then rename the new file. That way if the file fails to upload then you don't lose the old one.
If you need any further assistance with what I mentioned, feel free to contact me.
-
Received my copy today (in UK). I look forward to going through it after work.
-
If you could post your code we'd gladly try and correct it for you
-
I have mine on pre-order here in the UK and they still don't know when it will be released. No date as of yet.
-
It is possible, not that I have tested it.
// Send the content information: header('Content-type:application/pdf'); header('Content-Disposition:inline;filename="' . $filename . '"'); $fs = filesize($file); header ("Content-Length:$fs\n"); // Send the file: readfile ($file); exit();
Replace $filename with your filename and $file with the path and filename to the requested file.
Please look at Larry's E-Commerce book/files for more information
-
-
It may not be the best way but one way is forwarding yourself to the same page with a success tag if the file uploaded successfully. Like...
header ("Location: {$_SERVER['PHP_SELF']}?success=y"); exit();
and in the code have something along the lines of
if (isset ($_GET['success']) && ($_GET['success'] == "y")) { echo '<h4>The file has been uploaded!</h4>'; }
That way if you click refresh it will just reload the page rather than uploading the file again.
- 1
-
I have not tried this but it's just something that I noticed that could possibly be wrong...
echo $q = "SELECT entry_id , title , date_updated , p1 , p2, FROM blog WHERE entry_id = $pid";
You say you entered echo in front of it, so I am ignoring that, but is it possibly the fact that you have a comma after p2?
-
Have you edited the .htaccess to mod_rewrite?
As without doing so your links will not work in the current format.
-
$q = "SELECT userid, username, email FROM users WHERE (username='$u' AND password=SHA1('$p')) AND active=null";
From the looks of it you need to change "active=null" to "active IS NULL".
$q = "SELECT userid, username, email FROM users WHERE (username='$u' AND password=SHA1('$p')) AND active IS NULL";
-
From what I gather, you are still wanting people to access the PDF files but ONLY if they are logged in? If so I think I have changed the code correctly below
<?php
if(isset($_GET['id'])&&(strlen($_GET['id']) == 40)&&(substr($_GET['id'],0,1) !='.')){
$file =PDFS_DIR.$_GET['id'];
// if all 3 conditons are true then the path is defined
if(file_exists($file)&&(is_file($file))) {
//SQL for the path to the pdf
$q = 'SELECT title, description, file_name FROM pdfs WHERE tmp_name = "'.mysqli_real_escape_string($dbc, $_GET['id']) .'"';
$r = mysqli_query($dbc, $q);
if(mysqli_num_rows($r) == 1) { // if everything is ok
$row = mysqli_fetch_array($r, MYSQLI_ASSOC);
$valid = true;
if(isset($_SESSION['user_id'])) { // instead of getting rid of this, check whether they are logged in instead
header('Content-type:application/pdf');
header('Content-Disposition:inline; filename="' .$row['file_name'] . '"');
$fs = filesize($file);
header("Content-Length:$fs\n");
readfile($file);
exit();
}else{ // if not logged in
$page_title = $row['title'];
include('./includes/header.html');
echo "<h3>$page_title</h3>";
if(isset($_SESSION['user_id'])) {
echo '<p class="error">Thank you for your interest in this content. Unfortunately your account has expired. Please <a href="renew.php">renew your account</a> in order to access this file</p>';
}else{
echo'<p class="error">Thank you for your interest in this content. You must be logged in as a registered user to view this file</p>';
} // You'd also need to get rid of this
echo"<div>{$row['description']}</div>";
include('./includes/footer.html');
}//End of user IF-ELSE - You need this, its the end of checking whether they are logged in
}// End of Mysqli_num_rows() IF - You'd also need this
}// End of file_exists() IF
}// End of $_GET['id'] IF
if(!$valid){
// if not VALID
//Set $page_title to error and display an error message
$page_title = "Error";
include('./includes/header.html');
echo '<p class="error">This page has been accessed in error.</p>';
include('./includes/footer.html');
}
?>
- 1
Help! One Rewriterule Not Working
in PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
Posted
Basically as you have said... Rewrite rule matches the first instance... in this example...
www.yourdomain.com/bf/events/26 and www.yourdomain.com/bf/news/26 would both match "RewriteRule ^bf/([A_Za-z0-9]+)/([0-9-]+)$ /bf/index.php?content=$1&event_id=$2"
Instead of trying to set 2 ReWriteRule's on this I would think the best way would be in the index.php itself, as there isn't really a way without changing the structure of the rules to get this to work.
Make the event_id and article_id as just id.
Take the last rule off and simply in the index.php make a if clause, for example:
Do the obvious checks of whether content and a id exist and whether they are valid etc. Also don't forget to set $event_id and $article_id above so then no error's appear.
Hope that helps