Jump to content

litebearer

Members
  • Posts

    2,356
  • Joined

  • Last visited

Everything posted by litebearer

  1. for starters... method and action go in the first form tag. delete the other form tags (but NOT the closing one). give your text input a name.
  2. consider 1. if end time is before start time, is it an error or does it span two dates? (how do you account for that) 2. is there more than one room? how do you account for that? 3. google PHP BETWEEN datetime
  3. Not 100% certain; however, I believe your mysql_select_db has to occur BEFORE any mysql_real_escape_string's
  4. As a start, field names use back tick ` NOT single quotes '
  5. Aside... It would be better (IMHO) if you did not use the same variable for different 'meanings'. ie $excess_taxable_income vs $tax; keeping $tax as being the tax dollars.
  6. My pleasure! Glad I could be of some help.
  7. Have you considered using a multidimensional array?
  8. if your system is running php correctly (odds are it is), and you have written your code properly, then people cannot 'see' your php code, so no worries. To test it run your login.php and view the source.
  9. using gd you can overlay images and save or display the result
  10. Take a look at this (it may point you in the right direction)... <?PHP session_start(); /* script to calculate annual percentage rate of a loan using monthly compounding fixed term fixed rate fixed payments */ /* gather data */ $payment = ((int) ($_POST['payment']*100))/100; $term = (int) $_POST['term']; $loan = ((int) ($_POST['loan']*100))/100; /* validate data */ if($payment<=0 || $term<=0 || $loan<=0) { $my_result = "You MUST enter all three values - try again"; $_SESSION['myresult'] = $my_result; header ("Location: roi00.php"); exit(); } if($payment >= $loan) { $my_result = "Payment must be less than Loan Amount - try again"; $_SESSION['myresult'] = $my_result; header ("Location: roi00.php"); exit(); } if($payment * $term <= $loan) { $my_result = "Total Payments are less than Loan Amount - try again"; $_SESSION['myresult'] = $my_result; header ("Location: roi00.php"); exit(); } if($loan !=){ } /* calculate addon rate, low rate, high rate */ /* DO NOT EDIT THIS SECTION */ $fv = $term * $payment; $interest = $fv - $loan; $years = $term/12; $addon = $interest / $loan / $years; $lo_i = $addon; $hi_i = $addon *100; /* create function DO NOT EDIT */ /* function returns the annual APR as a decimal */ function WhatRate($lo_i, $hi_i, $payment, $term, $loan) { $done = 0; while($done != 1) { $i = ($lo_i + $hi_i)/2/12; $x =1 + $i; $y =pow($x, $term); $z = 1/$y; $w = 1-$z; $u = $w/$i; $pv = $payment * $u; if($pv >$loan+.01) { $lo_i = ($lo_i + $hi_i) /2; }elseif($pv <$loan - .01) { $hi_i = ($lo_i + $hi_i) /2; }else{ $done=1; } } return $i *12; } $apr = WhatRate($lo_i, $hi_i, $payment, $term, $loan) * 100; setlocale(LC_MONETARY, 'en_US'); $my_result = " <table> <tr><td>Loan Amount: </td><td align=right>" . money_format('%i', $loan) . "</td></tr> <tr><td>Monthly Payment: </td><td align=right>" . money_format('%i', $payment) . "</td></tr> <tr><td>Number of Payments: </td><td align=right>" . $term . "</td></tr> <tr><td>Total Payback: </td><td align=right>" . money_format('%i', $fv) . "</td></tr> <tr><td>Total Interest Paid: </td><td align=right>" . money_format('%i', $interest) . "</td></tr> <tr><td>Addon Rate: </td><td align=right>" . number_format($addon*100, 4) . "%</td></tr> <tr><td>APY (simple interest rate): </td><td align=right>" . number_format($apr, 4) . "%</td></tr> </table>"; $_SESSION['myresult'] = $my_result; header ("Location: roi00.php"); ?> BTW if all the extras are added to the loan (ie NOT paid by borrower) then the rate does not change only the payment changes. IF, on the other hand, the extras are DEDUCTED from the loan at closing, THEN you subtract those values from the loan amount to reach a 'net pv' WHICH then would be used to calculate the new interest rate
  11. 1. echo $_GET['id'] 2. try putting single quotes around $id in your query
  12. Just a wild idea (senility taking effect); Could not one use a similar solution as used when outputting a blob image on a page? ie to out put text followed by a blob image (which uses header), one uses a 2nd file to output the blob, so it may appear next to text. Clear as mud?
  13. what is the value of $pieces[$i] and how many records in your table have that value?
  14. show us loadimages.php if you ARE placing your images in an array, this may help http://hub.lotsofcode.com/php-array-pagination/
  15. Although I personally store the images in a folder and simply put the image name in the database, you may want to check this link (note they use 2 files to display the image) http://www.techcubetalk.com/2009/01/tutorial-on-how-to-store-images-in-mysql-blob-field/ Also, very bad habit to use the same variable for 3 different purposes $image = mysql ("SELECT * FROM afbeeldingen WHERE id=$id"); $image = mysql_fetch_assoc($image); $image = $image['data']; maybe... $query = "SELECT * FROM afbeeldingen WHERE id='$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $image = $row['data'];
  16. I can sympathize with that; however, using mysql_real_escape_string should ALWAYS be used. As to 100% off the bat, sometimes means hardwork. Not said to demean, rather stating the realities of life. Too often we (ME) write lines and lines of code before we test. And yes, it can suck big time.
  17. Not sure if it is the ONLY way, but stripslashes will work. Is there a valid reason you don't want to use it?
  18. In order achieve what you seeking to do, you need some sort of 'order' to the data how will your script know if a 'piece of data' is missing in a particular line? ie as you now have it line 1 = name, date, father, mother line 2 = date, mother as you should have it line 1 = name, date, father, mother line 2 = ,date,,mother EDIT: use tilde rather than commas
  19. have a go at this... <?php error_reporting(E_ALL); session_start(); require_once('appvars.php'); require_once('connectvars1.php'); echo "<PRE>"; print_r($_SESSION); echo "</pre>"; echo "<PRE>"; print_r($_GET); echo "</pre>"; // Connect to the database $dbc = mysqli_connect(DB_Host, DB_User, DB_Password, DB_Name); if (!isset($_GET['user_id'])) { $query = "SELECT * FROM antique WHERE user_id = '" . $_SESSION['user_id'] . "'"; }else{ $query = "SELECT * FROM antique WHERE user_id = '" . $_GET['user_id'] . "'"; } echo $query; exit(); $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The user row was found so display the user data $row = mysqli_fetch_array($data); echo '<table>'; if (!empty($row['name'])) { echo '<tr><td class="label">Name:</td><td>' . $row['name'] . '</td></tr>';} if (!empty($row['phone'])) { echo '<tr><td class="label">Phone:</td><td>' . $row['phone'] . ' </td></tr>';} if (!empty($row['address1'])) { echo '<tr><td class="label">Address1:</td><td>' . $row['address1'] . ' </td></tr>';} if (!empty($row['address2'])) { echo '<tr><td class="label">Address2:</td><td>' . $row['address2'] . ' </td></tr>';} if (!empty($row['postcode'])) { echo '<tr><td class="label">Postcode:</td><td>' . $row['postcode'] . ' </td></tr>';} if (!empty($row['webadd'])) { echo '<tr><td class="label">Web address:</td><td>' . $row['webadd'] . ' </td></tr>';} if (!empty($row['username'])) { echo '<tr><td class="label">Username:</td><td>' . $row['username'] . ' </td></tr>';} echo '</table>'; echo '<class = "label">USER ID: ' . $row['user_id'] . ''; if (!isset($_GET['user_id']) || ($_SESSION['user_id'] == $_GET['user_id'])) { echo '<p>Would you like to <a href="index5.php">Go to Homepage</a>?</p>'; } }else{ echo '<p class="error">There was a problem accessing your profile.</p>'; } echo "<hr>"; if (isset($_POST['submit'])) { // Grab the profile data from the POST $name = mysqli_real_escape_string($dbc, trim($_POST['name'])); $phone = mysqli_real_escape_string($dbc, trim($_POST['phone'])); $address1 = mysqli_real_escape_string($dbc, trim($_POST['address1'])); $address2 = mysqli_real_escape_string($dbc, trim($_POST['address2'])); $postcode = mysqli_real_escape_string($dbc, trim($_POST['postcode'])); $webadd = mysqli_real_escape_string($dbc, trim($_POST['webadd'])); $email = mysqli_real_escape_string($dbc, trim($_POST['email'])); $old_picture = mysqli_real_escape_string($dbc, trim($_POST['old_picture'])); $new_picture = mysqli_real_escape_string($dbc, trim($_FILES['new_picture']['name'])); $new_picture_type = $_FILES['new_picture']['type']; $new_picture_size = $_FILES['new_picture']['size']; $username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $user_id = mysqli_real_escape_string($dbc, trim($_POST['user_id'])); if (!empty($_FILES['new_picture']['tmp_name'])) { list($new_picture_width, $new_picture_height) = getimagesize($_FILES['new_picture']['tmp_name']); } //list($new_picture_width, $new_picture_height) = getimagesize($_FILES['new_picture']['tmp_name']); $error = false; // Validate and move the uploaded picture file, if necessary if (!empty($new_picture)) { if ((($new_picture_type == 'image/gif') || ($new_picture_type == 'image/jpeg') || ($new_picture_type == 'image/pjpeg') || ($new_picture_type == 'image/png')) && ($new_picture_size > 0) && ($new_picture_size <= MM_MAXFILESIZE) && ($new_picture_width <= MM_MAXIMGWIDTH) && ($new_picture_height <= MM_MAXIMGHEIGHT)) { if ($_FILES['new_picture']['error'] == 0) { // Move the file to the target upload folder $target = MM_UPLOADPATH . basename($new_picture); if (move_uploaded_file($_FILES['new_picture']['tmp_name'], $target)) { // The new picture file move was successful, now make sure any old picture is deleted if (!empty($old_picture) && ($old_picture != $new_picture)) { } }else { // The new picture file move failed, so delete the temporary file and set the error flag @unlink($_FILES['new_picture']['tmp_name']); $error = true; echo '<p class="error">Sorry, there was a problem uploading your picture.</p>'; } } }else{ // The new picture file is not valid, so delete the temporary file and set the error flag @unlink($_FILES['new_picture']['tmp_name']); $error = true; echo '<p class="error">Your picture must be a GIF, JPEG, or PNG image file no greater than ' . (MM_MAXFILESIZE / 1024) . ' KB and ' . MM_MAXIMGWIDTH . 'x' . MM_MAXIMGHEIGHT . ' pixels in size.</p>'; } } $error = false; // Update the profile data in the database if (!$error) { if (!empty($name) && !empty($phone) && !empty($address1) && !empty($address2) && !empty($postcode)) { // Only set the picture column if there is a new picture // Only set the password in there is a new one if (!empty($new_picture)) { // if (!empty($age)) { $query = "UPDATE antique SET name = '$name', phone = '$phone', address1 = '$address1', address2 = '$address2', postcode = '$postcode', email = '$email', webadd = '$webadd', picture = '$new_picture', username = '$username' WHERE username = '" . $_SESSION['username'] ."'"; } }else{ $query = "UPDATE antique SET name = '$name', phone = '$phone', address1 = '$address1', address2 = '$address2', postcode = '$postcode', email = '$email', webadd = '$webadd', username = '$username' WHERE username = '" . $_SESSION['username'] . "'"; } // mysqli_query($dbc, $query) or die("<br>Query $query<br>Failed with error: " . mysqli_error($dbc) . '<br>On line: ' . __LINE__); // Confirm success with the user echo '<p>Your profile has been successfully updated. Would you like to <a href="viewprofile4.php">view your profile</a>?</p>'; mysqli_close($dbc); exit(); }else{ echo '<p class="error">You must enter all of the profile data (the picture is optional).</p>'; } }else { // Grab the profile data from the database $query="SELECT * FROM antique WHERE user_id= '" . $_SESSION['user_id'] . "'"; $data = mysqli_query($dbc, $query); $row = mysqli_fetch_array($data); if ($row != NULL) { $name = $row['name']; $phone = $row['phone']; $address1 = $row['address1']; $address2 = $row['address2']; $postcode = $row['postcode']; $email = $row['email']; $webadd = $row['webadd']; $old_picture = $row['picture']; $username = $row['username']; $user_id = $row['user_id']; }else { echo '<p class="error">There was a problem accessing your profile.</p>'; } } mysqli_close($dbc); ?> <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MM_MAXFILESIZE; ?>" /> <fieldset> <legend>Personal Information</legend> <label for="name">Name:</label> <input type="text" id="name" name="name" value="<?php if (!empty($name)) echo $name; ?>" /><br /> <label for="phone">Phone:</label> <input type="text" id="phone" name="phone" value="<?php if (!empty($phone)) echo $phone; ?>" /><br /> <label for="address1">Address1:</label> <input type="text" id="address1" name="address1" value="<?php if (!empty($address1)) echo $address1; ?>" /><br /> <label for="address2">Address2:</label> <input type="text" id="address2" name="address2" value="<?php if (!empty($address2)) echo $address2; ?>" /><br /> <label for="postcode">Postcode:</label> <input type="text" id="postcode" name="postcode" value="<?php if (!empty($postcode)) echo $postcode; ?>" /><br /> <label for="email">Email:</label> <input type="text" id="email" name="email" value="<?php if (!empty($email)) echo $email; ?>" /><br /> <label for="webadd">Web address:</label> <input type="text" id="webadd" name="webadd" value="<?php if (!empty($email)) echo $webadd; ?>" /><br /> <input type="hidden" name="old_picture" value="<?php if (!empty($old_picture)) echo $old_picture; ?>" /> <label for="new_picture">Picture:</label> <input type="file" id="new_picture" name="new_picture" /> <?php if (!empty($old_picture)) { echo '<img class="profile" src="' . MM_UPLOADPATH . $old_picture . '" alt="Profile Picture"style="max-width:150px; max-height:110px" />'; } ?> <br /> <label for="username">Username:</label> <input type="text" id="username" name="username" value="<?php if (!empty($username)) echo $username; ?>" /><br /> <label for="user_id">User ID:</label> <input type="text" id="user_id" name="user_id" value="<?php if (!empty($user_id)) echo $user_id; ?>" /><br /> </fieldset> <input type="submit" value="Save Profile" name="submit" /> </form> <?php echo '<p class="login">You are logged in as ' . $_SESSION['username'] . '. <a href="logout3.php">Log out</a>.</p>'; echo '<class = "label">USER ID: ' . $row['user_id'] . ''; ?> <p><a href="index.php">Return to homepage</a></p> <?php require_once('footer.php'); ?> </body> </html>
  20. 1. consider each line as a record, use the carriage return as separator for each line 2. As mentioned above use the tilde ~ as the delimiter between 'fields' 3. make sure each 'record' has the same number of 'fields'; even if they are blank 4. save as txt file 5. read into php via file() as this will create an array in which each element is a line from your file.
  21. If it is auto-increment, then yes
  22. might also look at... http://www.binarymoon.co.uk/2010/08/timthumb/
×
×
  • 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.