Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. ahhh I see, well then in that case, sure that would work. try that and see what happens
  2. well.. you never included anything <?php require_once('../Connections/MySQL.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO lessonplan (FName, LastName, school, CourseName, GradeLevel, Dates, LessonTitle, FrameworkSubject, essential, understand, Skills, realworld, pertasks, otherevidence, otherev, Activities, resources, Modifications, othermod, accelmodifications, othermodacc) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['FName'], "text"), GetSQLValueString($_POST['LastName'], "text"), GetSQLValueString($_POST['school'], "text"), GetSQLValueString($_POST['CourseName'], "text"), GetSQLValueString($_POST['GradeLevel'], "text"), GetSQLValueString($_POST['Dates'], "text"), GetSQLValueString($_POST['LessonTitle'], "text"), GetSQLValueString($_POST['FrameworkSubject'], "text"), GetSQLValueString($_POST['essential'], "text"), GetSQLValueString($_POST['understand'], "text"), GetSQLValueString($_POST['Skills'], "text"), GetSQLValueString($_POST['realworld'], "text"), GetSQLValueString($_POST['pertasks'], "text"), GetSQLValueString($_POST['otherevidence'], "text"), GetSQLValueString($_POST['otherev'], "text"), GetSQLValueString($_POST['Activities'], "text"), GetSQLValueString($_POST['resources'], "text"), GetSQLValueString($_POST['Modifications'], "text"), GetSQLValueString($_POST['othermod'], "text"), GetSQLValueString($_POST['accelmodifications'], "text"), GetSQLValueString($_POST['othermodacc'], "text")); mysql_select_db($database_MySQL, $MySQL); $Result1 = mysql_query($insertSQL, $MySQL) or die(mysql_error()); $insertGoTo = "thanks.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } //header(sprintf("Location: %s", $insertGoTo)); dont need this include("thanks.php"); exit();//only include this is you DONT want to output the HTML below this line } ?>
  3. that would work for a while, I suppose, but you will eventually run out of letters. Assuming every letter is for a certain range (IE may 1st through may 11th) you will eventually run out of letters to use. I would suggest using the month, and whatever 3rd of the month it is. Forexample, if a bill falls under may 4th, then it would be in the first 3rd, so the end may look like ClientA-May-1 something for may 15th may look like ClientC-May-2 etc.
  4. post the code. lets see what you got
  5. Yeah I figured you had a situation like that. Perhaps you should think of a different naming scheme all together? I know that isn't the easiest way to solve the problem, but it may make adding different functionality in the future much easier also
  6. //after stuff include("thankyoupage.php"); or just copy and paste the stuff from the thankyou page to the end of the other page.
  7. this is just a wild stab but couldn't the following: $btdate = 'billing_tickets/*_9-*-*-*-*-*.txt'; that could get all the files made in the month of september. Using this logic you could grab bills from a year, or a certain day, or even a certain hour. This is somewhat limited however in that you can't get a range between any two dates. Just a stab in the dark, as I haven't used the glob function much
  8. sessions have no connection to registration. As long as there is a column that has a unique value for every row, you can get that value and store it to a session, and then retrieve that row on any page that has access to that session. However, since you are using a header for a redirect, It would be hard to use hidden fields, because you will have to submit the form somehow, and I don't believe you can do that if you are using a header redirect. Besides, since you are using headers, there is obviously no output, why don't you just include the thankyou page after you process the form?
  9. how do you tell which link has been pressed? is there a get variable passed or something?
  10. why not just set the value attribute with php like <input type="textbox" value="<? echo $comment; ?>" /> I know the type isn't textbox but the important part is the value part. but if you must do javascript, have you checked to see that there aren't any errors in the javascript? check your JS error logs if you have one. If your in firefox just press ctrl + shift + j
  11. Post data does not go from page to page unless it is submitted. Since no form data was submit to your thanks.php page, it doesn't have access to it like the page before it did. if you want that to have access to the form data you are going to have to pass it through hidden fields and submit those hidden fields when you go through the page. alternatively, when someone registers, you can set a session with their specific id, or other primary key for your table, and draw the row that was just insert with that id and generate the values again.
  12. Ahh i see your problem. Yes the function you want to use is file_get_contents as tendolla has said.
  13. Well, basically PHP connects to a mysql database. Once in that database, it can interact with certain tables. PHP does what are called "queries" which are basically commands written in the sql language. For example, if you wanted to select everything from a table, the query would look like this SELECT * FROM table additionally, if you wanted to only retrieve two columns from a table the query would look like this SELECT column1, column2 FROM table However, for something like a login system, you only want to pull data from the table if it matches certain columns, say... the username and password column. well a query for the user joe with password pass would look like Select * from table WHERE username='joe' AND password='pass' assuming that the column that stores usernames is called "username" and the column that stores passwords is called "password". Simple enough right? Now where does PHP come in all this? Well, SQL doesn't really have variables in the sense that php does. But since you can run Mysql queries in PHP, you can also use PHP variables in those queries. So say you wanted to select everything from a table, but you wanted to store that table in a variable so you could save it for use in another script. Well you could do $table = "myTable"; //now the query //the syntax for a mysql queries goes as follows //do the query via the mysql_query() function //retrieve the results with mysql_fetch_array() or //one of the other retrieving functions $result = mysql_query("SELECT * from ".$table); //note how we used the variable in the query Simple enough right? Now if we wanted to retrieve the row for a specific user, we would so something like $user = 'Joe'; $pass = "pass"; $query = mysql_query("Select * From $table Where username='$user' AND password='$pass' LIMIT 1"); //limit 1 limits the amount of rows returned to 1 //now we get the array $row = mysql_fetch_array($query); //to access the info from the row we use the column names as keys for the array. //to greet the user we would do echo "Hello: ".$row['username']; Pretty simple right? And you could instead of hardcoding values into the variable, assign them to post variables, or whatever you want really. I suggest you google some simple PHP mysql tutorials to get the hang of how they interact, and once you understand, building what you want to build would be quite easy and fun! Hope that helps
  14. passing the values the way you are currently is passing them by get values. What you can do is create hidden forms, and have that link submit the form that those hidden fields are part of, but you can't hide the get variables from the URL unless you use Mod rewrite or something like that.
  15. Oh ok, well it will be hard to tell you whats wrong if you don't post the actual code you're working with
  16. just storing the value in a variable won't echo it out. What does your include page look like? if it looks like the first php you posted, don't assign the variable, just write the code, and when you include it the code will be executed.
  17. $sql =mysql_query(select * from table); should be $sql =mysql_query("select * from table"); I'm suprised you aren't getting any errors
  18. this is somewhat pointless and long, and can be avoided with a few loops. while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $finish[$i] = $row[2]; $centre_name[$i] = $row[1]; $i++; } switch(mysql_num_rows($results)){ case "4": echo 'your nearest 4 centre are '.$centre_name['0'] . ", " .$centre_name['1'] . ", " .$centre_name['2'] . ", and " .$centre_name['3'] ; break; case "3": echo 'your nearest 3 centre are '.$centre_name['0'] . ", " .$centre_name['1'] . ", and " .$centre_name['2']; break; case "2": echo 'your nearest 2 centre are '.$centre_name['0'] . ", and " .$centre_name['1']; break; case "1": echo 'your nearest centre is '.$centre_name['0']; break; case "0": echo "no records found"; break; case "5": default: echo 'your nearest 5 centre are '.$centre_name['0'] . ", " .$centre_name['1'] . ", " .$centre_name['2'] . ", " .$centre_name['3'] . ", and " .$centre_name['4']; } You can make your loop like this while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $finish[] = $row[2]; $centre_name[] = $row[1]; } which saves a few lines of code, but when building the return string, do something like $string = "Your nearest ".count($centre_name); string .= (count($centre_name) > 1) ? " events are " : " event is ";//will put an is if only 1 and an are if more than 1 //now go through the array, and add the values to string foreach($centre_name as $key => $name){ $string .= $name; $string .= ($key != (count($centre_name) - 1)) ? ", " : " ";//will add a comma if we aren't at the end. if not just add a space } echo $string with the following test data $centre_name = array("dog", "cat", "mouse"); $string = "Your nearest ".count($centre_name); $string .= (count($centre_name) > 1) ? " events are " : " event is ";//will put an is if only 1 and an are if more than 1 //now go through the array, and add the values to string foreach($centre_name as $key => $name){ $string .= $name; $string .= ($key != (count($centre_name) - 1)) ? ", " : " ";//will add a comma if we aren't at the end. if not just add a space } echo $string the script returned Your nearest 3 events are dog, cat, mouse
  19. you have to set the content type on your header. something like $headers .= "Content-type: text/html"; should do the trick
  20. As i understood, he wasn't talking about submitting blank form info, but a user going directly to the page that processes the form, and since they didn't go through the form, all the form data would be blank. Not to mention that every other reply in this thread uses the same logic, and in your example wouldn't work either... All the replies in this thread call the isset function on the submit key of the post variable, but none of them do any data quality checks, so fundamentally, your post applies to every answer in this thread. But you are correct, you should also make sure that the post variables are set to something before you insert them into the databse
  21. this seems easy enough, but without seeing your actual array I can only give an educated guess $array;//this is your full array $array[0];//this is the second level of your array $array[0][0];//this is the third level of your array to add a new entry to the third level just do $array[0][0][] = $new_array; //where new_array is the array that is being pushed into the 3rd level of your array is that what you're looking for?
  22. or just do a quick check if its submit and do an error message if its not, and exit. this way you don't have to surround the process with an if or else block, but you get the same effect if (!isset($_POST['submit'])){ echo "error"; exit(); } //do processing either way all the examples given in this post would work perfectly for you
  23. well of course they return `warning` and `banned`.. thats what you set them as. And you are using them in the query.. the variable that pulls the values of those columns in the database is the $row variable. However, the problem is that your query isn't returning any rows for some reason. Do a var dump on your query as it stands currently, and run that same query in PHPmyadmin or SQL itself.
  24. do the same query in PHPMYADMIN and see if you get the same results. If so, then your table is empty. Beyond that I don't really know what to tell you, seeing as I just did the same query and it worked perfectly
  25. old well dude $query = "SELECT $warning1$ FROM $tbl"; that should be $query = "SELECT $warning1, $banned1 FROM $tbl"; shouldnt it
×
×
  • 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.