Jump to content

Wayniac

Members
  • Posts

    89
  • Joined

  • Last visited

    Never

Everything posted by Wayniac

  1. Awesome, thank you.
  2. Thanks for the tip, is there any advantage to why I would use empty()? Is the other depreciated?
  3. Thank you onlyican, that worked perfectly.
  4. I think I could reword it a little better. I'm trying to accomplish an action from an if statement that will work if anything from a space, to a letter, to a full fledge word is entered in the value spot within the "". Ex: <?php if ($fname == "ANYTHING") { // But I can't just put ANYTHING in that slot via server side, it would have to be typed. //blah blah } ?>
  5. Hello all, Just a quick one here, I'm not sure what to put in the quotations of an if statement if I want to say if value equals ANYTHING. Thanks
  6. Thank you all so much! The level code works wonderfully. The idea of using levels instead of names is brilliant, I should have planned it more before jumping right into it. Once again, thank you all so much, I'm going to go check out some of the usful links you all posted above. Thank you!
  7. Oh haha, sorry must have been an old code. I'm still getting this error: Parse error: syntax error, unexpected '{' in /mnt/w0340/d16/s01/b02c73a9/www/lifelikemedia.ca/wtt/crm/login.php on line 28 This is line 28: if(!in_array($_SESSION["username"] , $only){ But it needs to have that there....
  8. Thank you Dezkit, I am following your code at the moment, but I may have made a mistake with my syntax. Here is the code below. <?php // load the configuration file. include("config.php"); ?> <? // Use session variable on this page. This function must put on the top of page. session_start(); ////// Logout Section. Delete all session variable. session_destroy(); $message=""; ////// Login Section. $Login=$_POST['Login']; if($Login){ // If clicked on Login button. $username=$_POST['username']; $password=$_POST['password']; // Check matching of username and password. $result=mysql_query("select * from admin where username='$username' and password='$password'"); if(mysql_num_rows($result)!='0'){ // If match. //session_register("username"); // Create session username. //$_SESSION['username'] // Create session username. $_SESSION['username'] = $username; $only = array("john"); if(!in_array($_SESSION["username"] , $only){ header("location:intheloop.php"); // Re-direct to intheloop.php } exit; }else{ // If not match. $message="Invalid Username or Password<br>"; } } // End Login authorize check. ?>
  9. Thank you PFMaBiSmAd and radar. What I am attempting to accomplish is to have several usernames and restricted access for them to some pages, but not others. So John would have access to example1.php, but not example2.php and emily vice-verse, etc. Here is my complete code below: <?php // load the configuration file. include("config.php"); ?> <? // Use session variable on this page. This function must put on the top of page. session_start(); ////// Logout Section. Delete all session variable. session_destroy(); $message=""; ////// Login Section. $Login=$_POST['Login']; if($Login){ // If clicked on Login button. $username=$_POST['username']; $password=$_POST['password']; // Check matching of username and password. $result=mysql_query("select * from admin where username='$username' and password='$password'"); if(mysql_num_rows($result)!='0'){ // If match. $_SESSION['username'] // Create session username. header("location:intheloop.php"); // Re-direct to intheloop.php exit; }else{ // If not match. $message="Invalid Username or Password<br>"; } } // End Login authorize check. ?> PS: Trying what you posted will35010, thank you.
  10. Hello everyone, I'm attempting to find only a specific username in this field "username" located in the database. The code below works when with the rest of the I left out since its not important for this problem. What I would like to do is have it so if I type in the name "john, emily, or chris", and if the name is in the field, then it works. session_register("username"); // Working code, username is the field name. Ex: session_register("john | emily | chris"); // Example code, populated with values. I would like to work the same, except with values instead of using the field name. Let me know if you need any further clarification, thank you.
  11. If I can reword or explain a specific section in more detail, please let me know and I'll do so. Thank you
  12. Below is my previous code I had working in the manner it would change the price, sub_total, tax, sh, total, and total_paid input fields to 0. There are two problems with this... 1. When it outputs to the input fields, the value displays as 0 instead of 0.00. 2. I need to have it only react when the value typed into the input field "trees_sold" is "0". If any higher, I would like it to ignore the statement. <!-- Comp all prices to zero value --> <SCRIPT LANGUAGE="JavaScript"> var trees_sold = 0.00; function InitSaveVariables(form) { price = form.price.value; sub_total = form.sub_total.value; tax = form.tax.value; sh = form.sh.value; total = form.total.value; total_paid = form.total_paid.value; } function CompPrices(form) { if (trees_sold == 0.00) { InitSaveVariables(form); form.price.value = 0.00; form.sub_total.value = 0.00; form.tax.value = 0.00; form.sh.value = 0.00; form.total.value = 0.00; form.total_paid.value = 0.00; } } </script> <input name="trees_sold" id="trees_sold" size="15" onkeyup="javascript:CompPrices(this.form);" maxlength="15" /> Below is my current code I'm working with that I can't seem to get to function properly. I've modified the first two lines of code here, and am attempting to pull any data that is typed in and automatically take into consideration if it is a "0" value, it reacts as my code below says "if (trees_sold == 0.00)" and if anything else, it will not do anything. This is not working unfortunately. <!-- Comp all prices to zero value --> <SCRIPT LANGUAGE="JavaScript"> form.trees_sold.value = ""; trees_sold = form.trees_sold.value; function InitSaveVariables(form) { price = form.price.value; sub_total = form.sub_total.value; tax = form.tax.value; sh = form.sh.value; total = form.total.value; total_paid = form.total_paid.value; } function CompPrices(form) { if (trees_sold == 0.00) { InitSaveVariables(form); form.price.value = 0.00; form.sub_total.value = 0.00; form.tax.value = 0.00; form.sh.value = 0.00; form.total.value = 0.00; form.total_paid.value = 0.00; } } </script> <input name="trees_sold" id="trees_sold" size="15" onkeyup="javascript:CompPrices(this.form);" maxlength="15" /> Anyone have any ideas? Thank you.
  13. I think I understand now. You definatly set me in the right direction. I will have to do more research, otherwise I'm just typing and not learning. Once again, thank you so much
  14. Sorry, I'm not usually this confused, perhaps I'm just really tired. Could you tell me how I can get my field "ship_date" which is on my webpage that sends off the data to my mysql database when submitted to either be stored as MM-DD-YYYY or when I try an retrieve it on my other page that views the entry to be displayed as MM-DD-YYYY. Sorry if I'm making this difficult for you, I really do appreciate you helping me.
  15. Once again, thank you so much. But was I suppose to run this query through a php code? This is what happens when I enter it in the phpmyadmin SQL section: DATE_FORMAT( date_ship, '%m/%d/%Y' ) 00/00/0000 Which is great, but when I browse the fields section, its still 0000/00/00? You said earlier the database format never changes, how would I approach this then? Thank you
  16. If I attempt to paste the following into the phpmyadmin SQL section: SELECT DATE_FORMAT(date_ship, '%m/%d/%Y') It gives me this error: Error SQL-query : SELECT DATE_FORMAT( date_ship, '%m/%d/%Y' ) MySQL said: Unknown column 'date_ship' in 'field list' Back There is indeed a field with this exact spelling "date_ship" in the table.
  17. Thank you for your quick reply PFMaBiSmAd. So do you mean I would have to run this through a php query? Also, do you have enther an example or know of any tutorials that demonstrate this. I'm having a hard time finding such a thing, I figured this would be a pretty standard procedure given how common it is on the web.
  18. Hello everyone, I'm attempting to convert my date format for mysql database from YYYY-MM-DD to MM-DD-YYYY. It seems to say it works to my little understanding of this process, but nothing changes. This is the SQL code I used in phpmyadmin. SELECT DATE_FORMAT(CURDATE(), '%m/%d/%Y') This is the message I got afterwards. 06/30/2010 If I browse that field in phpmyadmin, it still shows the following format: 0000-00-00 Any suggestions? Thank you everyone.
  19. Thank you so much, that worked 100% your so amazing!
  20. Hello everyone, Below I have a HTML code with a bit of PHP that is only calling its partners in crime so to speak. That is not the priority here, the edit code works fine for any textboxes that needs editing, but is not for the drop down boxes. Let me explain further... In a previous page, I will set the dropdown box to ex: Spring 2011, and that accepts correctly in the database. It even carries over fine with the example textbox I placed in the code below. But the dropdown box defaults to the first item in the list, which would be Fall 2010. Now I can change this and submit with either the example textbox or even the dropdown box and it will work, that is not the issue. My issue is that the dropdown box will not keep the value that is stored in the database, but the textbox example will. I will explain my idea I have for overcoming this... I was thinking if I use a hidden textbox to receive the value, and then somehow (my problem) have the dropdown box which has the same name as the textbox be set so it reads the textbox and changes to that value. Does anyone have an idea on how I can get this to work? Any thought on this topic would be a great asset to me finishing this dilemma. Here is the basic HTML code below... <select name="ship_season" class="textBox_center" id="ship_season" style="min-width:200px;" value="<?php echo $ship_season; ?>"> <option value="Fall 2010">Fall 2010</option> <option value="Spring 2010">Spring 2010</option> <option value="Fall 2011">Fall 2011</option> <option value="Spring 2011">Spring 2011</option> </select> <input name="ship_season" id="ship_season" value="<?php echo $ship_season; ?>"/> Thank you all so much.
  21. Thank you so much, I took what you said and applied from what I learned of the tutorial from that link and it works perfectly now. I posted the working code below. Once again for future readers, this will allow the user to filter out between dates. Thank you so much // CLIENT SIDE <form action="<?=$PHP_SELF?>" method="post" name="search2" id="search2"> <input type="hidden" name="field" value="date"/> Select a date: <br /> <input name="datefrom" type="text" id="datefrom" size="15"/> <br /> <input name="dateto" type="text" id="dateto" size="15"/> <input type="hidden" name="searching2" value="yes" /> <input type="submit" name="search" value="Search" /> </form> // SERVER SIDE <? //This is only displayed if they have submitted the form if ($searching2 =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($datefrom == "") { echo "<p>You forgot to enter a search term"; exit; } if ($dateto == "") { echo "<p>You forgot to enter a search term"; exit; } $datefrom = trim ($_POST["datefrom"]); // and do whatever filtering you want $dateto = trim ($_POST["dateto"]); // and do whatever filtering you want // do the same query thing with the link you found with the variables above // for anything additional entry for search like an entity to be used for LIKE, add the one you have in WHERE concatenated with AND //Now we search for our search term, in the field the user specified # $data = mysql_query("SELECT * FROM spreadsheet WHERE upper($field) BETWEEN'$datefrom' AND '$dateto'"); //$data = mysql_query("SELECT * FROM spreadsheet WHERE upper($field) LIKE'$dateto'"); //And we display the results while($myrow = mysql_fetch_array( $data )) { echo "<b>First Name: </b>"; echo $myrow['fname']; echo "<b>Last Name: </b>"; echo $myrow['lname']; echo "<b>Date: </b>"; echo $myrow['date']; echo "<b>Address: </b>"; echo $myrow['ship_add']; echo "<b>City: </b>"; echo $myrow['ship_city']; echo "<b>State: </b>"; echo $myrow['ship_state']; echo "<b>Zip: </b>"; echo $myrow['ship_zip']; echo "<a href=\"wpi_more.php?spreadsheetid=" . "$spreadsheetid" . $row["spreadsheetid"] . "\">" . "Read" . "</span>" . "</a>"; // Now print the options to (Read,Edit & Delete the entry) echo "<hr align=left width=620 color=\"#4e592f\">"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$datefrom; echo "<b>Searched For:</b> " .$dateto; } ?>
  22. Thank you bluejay for replying, Looking back at this now, I can see puting two of the same would do nothing (very tired), do you have any suggestion on how I might approach this?
  23. Greetings everyone, I'm attempting to set up a search for a FROM date and a TO date so it will filter out specific records. The search works fine, my only deviations in the script below is I added two "find2" textboxes where normally there is only one. I found a link to a presumable working code that allows me to do such. But am uncertain on how to implement this change. I will provide the link below. http://www.daniweb.com/forums/thread53025.html Thank you all in advance // CLIENT SIDE (Allows the user to search for a record by entering a FROM date and a TO date.) <form action="<?=$PHP_SELF?>" method="post" name="search2" id="search2"> <input type="hidden" name="field" value="date"/> Select a date: <br /> <input name="find2" type="text" id="find2" size="15"/> <br /> <input name="find2" type="text" id="find2" size="15"/> <input type="hidden" name="searching2" value="yes" /> <input type="submit" name="search" value="Search" /> </form> // SERVER SIDE (Enables the option to search for a date of a specific entry and present the full record.) <? //This is only displayed if they have submitted the form if ($searching2 =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find2 == "") { echo "<p>You forgot to enter a search term"; exit; } // We preform a bit of filtering $find2 = strtoupper($find2); $find2 = strip_tags($find2); $find2 = trim ($find2); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM spreadsheet WHERE upper($field) LIKE'$find2'"); //And we display the results while($myrow = mysql_fetch_array( $data )) { echo "<b>First Name: </b>"; echo $myrow['fname']; echo "<b>Last Name: </b>"; echo $myrow['lname']; echo "<b>Date: </b>"; echo $myrow['date']; echo "<b>Address: </b>"; echo $myrow['ship_add']; echo "<b>City: </b>"; echo $myrow['ship_city']; echo "<b>State: </b>"; echo $myrow['ship_state']; echo "<b>Zip: </b>"; echo $myrow['ship_zip']; echo "<a href=\"wpi_more.php?spreadsheetid=" . "$spreadsheetid" . $row["spreadsheetid"] . "\">" . "Read" . "</span>" . "</a>"; // Now print the options to (Read,Edit & Delete the entry) echo "<hr align=left width=620 color=\"#4e592f\">"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find2; } ?>
  24. Thank you everyone! karpagam, that fixed my problem entirely, thank you so much, I see what was happening now, I really appreciate everyone helping me to figure this issue out
  25. Thank you for replying F1, I tried as you said by removing the IF statement and nothing has changed. The IF statement was completely pointless to have in there, but also me removing it had no effect. It still prompts the user twice...
×
×
  • 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.