Jump to content

rich_traff

Members
  • Posts

    44
  • Joined

  • Last visited

Everything posted by rich_traff

  1. Hi mjdamato, the situation is this, It is for a car booking component where a user can book out a car for varying lengths of time at different rates. rate 1 = '1 day' (any one day mon - fri) rate 2 = '1 week' (any full 7 day week, so could be wed - tues) rate 3 = '1 weekend' (any sat - sun) So if someone booked 9 days starting on a tues, i need to calculate the cost for 1 full week and 2 days If someone booked 3 days starting fri = 1 day & 1 weekend I actually haven't considered what happens if someone just wants a sat or sun, but for now will treat it as any booking that falls onto either a sat or sun as 1 full weekend, ie - fri to sat = 1 day & 1 weekend
  2. Hi, i need to calculate the number of weekends, full weeks and any remaining week days (mon - fri, outside of full weeks) between any 2 dates stored as unix timestamp. Can anyone suggest how to approach this? obviously i can work out the number of total days easily with some math and from that work out the full weeks and remaining total days, i dont know where to start factoring in the weekends though... can anyone help?
  3. I assumed as much, what i am currently doing is the following; 1) INSERT query into comments table 2) SELECT latest entry from comments table 3) INSERT query into course table (using the data from the latest comments entry) This is working, however im concerned that potentially 100's of people could all be writing comments at the same time and SELECT last entry might not pick up the right comment id... So am wondering if theres a better way?
  4. Hi, i need to update 2 MySQL tables in 1 go using PHP Im posting from a comment form. The tables that i have are; TABLE: Comments [ commentId ] [ comment ] [ userId ] [ courseId ] [ partId ] TABLE: Course [ userId ] [ part1_comment ] [ part2_comment ] [ part3_comment ] In the comments table the 'commentId' auto increments. What i want to happen is when someone posts a comment; 1) it gets added to the comments table as a new entry 2) the 'commentId' for that entry is recorded and an entry is made in the course table with that 'commentId' being put into the relevant 'part_comment' Im assuming this kind of thing is a 'fairly' regular occurrence so am wondering if theres any best practice ways of approaching it? Also, if theres any potential problems that could occur if many people are posting comments at the same time and how they can be avoided… Any advice would be appreciated.
  5. Hi, i have written a form that uses 3 dropdown boxes, one of them being populated from a database. The form code is as follows; <form id="pointsForm" name="pointsForm" method="post" action="points-engine.php"> <select name="car" id="car"> <?php // result of car name collection $result = mysql_query ($query); //Array stored in $cars while($cars=mysql_fetch_array($result)){ //option values added by looping through array echo "<option value=$cars[id]>$cars[carName]</option>"; } ?> </select> <select name="season" id="season"> <option value="low">Low season</option> <option value="mid">Mid season</option> <option value="high">High season</option> <option value="peak">Peak season</option> </select> <select name="period" id="period"> <option value="day">One day</option> <option value="weekend">Weekend</option> <option value="week">One week</option> </select> <input type="submit" name="Submit" value="Submit" /> </form> which posts to; <?php $car=$_POST['car']; echo $car; $season=$_POST['season']; echo $season; $period=$_POST['period']; echo $period; ?> The initial form code is working fine, the car field is being populated from the database. My problem is the post value for car isn't working... points-engine.php is echoing $season & $period fine but not $car can anyone tell me why? many thanks Richard
  6. Well mainly in this instance because i am building this as a freelancer for an agency, but still hosting on my server. The agency wouldn't want the client to trace direct back to me... How would i go about this? Im setting them up a new email to handle these enquires so will have the password...
  7. Hi, I've put together a callback request form that emails my client when someone fills it out. the form is as follows <form method="post" action="php/callbackform.php"> Name: <input name="name" type="text" /><br /> Phone number: <input name="phone" type="text" /><br /> no: <input type="checkbox" name="no" value="This customer does not want their information to be used for marketing purposes" /><br /> <input type="submit" /> </form> it posts to this code <?php $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $optout = $_REQUEST['no'] ; $message = $phone . " " . $optout; mail( "client@example.com", "Call back form request", $message, "From: $name" ); header( "Location: http://www.example.com/index.php" ); ?> The problem is that when the email is received, the email 'from' field shows my servers default email address. So if someone called bob filled out the form the resulting email would show as; From: bob<default@myserver.com> My client doesn't want to add an email box to use as the from address so is there anyway i can hide my address being included in the email header? thanks Richard
  8. Hi, im trying to apply a random css class to a div so that a random image is generated on each refresh. This is the code i am using to apply the class. <div class="<?php echo($randomimage); ?>"> Say i have an array of $image1 $image2 $image3 etc, how can i make $randomimage = 1 of these at random on each refresh? I've found lots of tutorials that generate a random number online but none that generate a random variable and am having trouble piecing this together. Any help would be hugely appreciated. Richard
  9. Hi Swisse, can you explain what you mean by the code location? i've used this line before to call other files with no problems ($_SERVER['DOCUMENT_ROOT']."/clientlogin/logout.php") or are you referring to something else? thanks
  10. Can anyone tell me why the following code isn't working? <?php //Start session session_start(); // set timeout period in seconds $inactive = 600; // check to see if $_SESSION['timeout'] is set if(isset($_SESSION['timeout']) ) { $session_life = time() - $_SESSION['timeout']; if($session_life > $inactive) { session_destroy(); header($_SERVER['DOCUMENT_ROOT']."/clientlogin/logout.php"); } } $_SESSION['timeout'] = time(); //Check whether the session variable SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) { header("location: access-denied.php"); exit(); } ?> Its to log a user out when they've been inactive for a length of time. - the script is working in the fact that after the allotted time the session seems to be destroyed, however - instead of redirecting the user to logout.php it is giving the following error [an error occurred while processing this directive] any advise would be appreciated...
  11. Thanks DevilsAdvocate, that sorted the error problem but the link still didn't work, i had to slightly amend it to the following <?php echo '<a href="'. $_SESSION['SESS_LAST_NAME'].'/vault/'.$_SESSION['SESS_FIRST_NAME'].'.php">Access files</a>'; ?> Is now working great though, thanks jd307 for your help here also, fully appreciated!
  12. ok, I've tried what you said and renamed the folders accordingly. I've stored the random number folder name in the second name field of the database (as its already set up) and checked that this is outputted in a session as 'SESS_LAST_NAME' My code now looks like this; <h2>Welcome to <?php echo $_SESSION['SESS_FIRST_NAME'];?></h2> <p>This is a password protected area. </p> <?php echo "<a href=\"" . $SESSION['SESS_LAST_NAME'] . "\vault\" . $SESSION['SESS_FIRST_NAME'] . ".php\">Access files</a>";?> <a href="logout.php">Logout</a> which is using your example only changing ['AUTH_DIR'] to ['SESS_LAST_NAME'] when i load this page now though i get the following error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home1/tweakmed/public_html/seeproductions/clientlogin/member-index.php on line 28 I've tripple checked the database through phpmyadmin that all folder names are correct and made sure the directory is correctly ordered but am unable to get around the error. Can you offer anymore advice? many thanks
  13. Hi jd307, thanks for your response. The 'SESS_FIRST_NAME' does relate to the first name of a user, but only because i hashed together a couple of other scripts id found (im fairly new to php). Theres no reason why it has to be the first name thats used to identify each page. At the moment the database entries made are 'first name' 'second name' 'username' & 'password' - however, the pages outputted do not need to relate to any new users and no new user will be signing up. What i am trying to do is create a backend file upload & download area for a client where he will have say 6 different directories that he can use for different clients at any one time. I've called them user1, user2 etc for now as im still building it, in reality they will likely be called 'file_vault1' 'file_vault2' or something similar. I can see how your example would work very well if all the files were kept in the same directory, however for this site, it is important that the php files to be loaded from each link be kept in its own directory. + as an added security measure i want to place each folder within another folder using a random name that wont be easily guessed. the file structure will be something like the following. client login login.php logout.php clientfiles aj3618fhs8 vault1 user1.php shc649tj16 vault2 user2.php gabd5386ld vault3 user3.php Its important that the files be structured in this way as the script i am using to upload/download files reads the files that are contained within the same folder it is in. ie - user1.php reads all the files that are uploaded to 'vault1'. Is it possible to adapt your example given to account for the directory structure? I realise an easy way to accomplish this would be to make 'SESS_FIRST_NAME' the whole file path. However the script i've used to create new database entries strips '/'s and im not confident enough with php to change this.... any thoughts would be greatly appreciated. Richard
  14. Hi, this is a piece of code i have which is part of the first page a user see's after logging in. <h2>Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?></h2> <p>This is a password protected area.</p> <a href="user1.php">Access files</a> | <a href="logout.php">Logout</a> people can login as either; user1, user2, user3 etc - depending on which user logs in, i want the 'access files' link to go to a specific page - ie, if you log in as user1 - the access files link will point to user1.php, if you login as user2 it will point to user2.php etc... Can anyone tell me how i can use the 'SESS_FIRST_NAME' value to control where the 'access files' link points to? many thanks Richard
×
×
  • 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.