Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. You can add JQuery accordion effect with a few changes to my example code <div class="content archive"> <h3><?php echo _("Archive"); ?></h3> <ul id="archiveList"> <!-- Give parent ul id --> <?php $startDate = strtotime('2011-10-01'); $endDate = strtotime(date('Y-m-d')); $startYear = date('Y', $startDate); $endYear = date('Y', $endDate); // loop through years for($year = $startYear; $year <= $endYear; $year++) { // calcuate start/end months $startMonth = ($year == $startYear) ? date('m', $startDate) : 1; $endMonth = ($year == $endYear) ? date('m', $endDate) : 12; $class = "archive$year"; $url = URL . "blog/archive/love/$year/"; // make new list item for year, enclose new list for months in year echo " <li><div>$year</div>\n <ul>\n"; // <-- wrap year with a div // loop through months for($month = $startMonth; $month <= $endMonth; $month++) { $_month = date('F', mktime(0, 0, 0, $month, 1, 0)); ?> <li class="archiveLink"> <p><a href="<?php echo URL . "blog/archive/love/$year/$month" ?>"><?php echo _($_month); ?><span>»</span></a></p> </li> <?php } // end enclosed month list echo " </ul>\n </li>\n"; } ?> </ul> </div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> // JQuery accordian $('#archiveList ul').slideUp(300); // on page load hide months (slides up) $("#archiveList > li > div").click(function(){ $(this).next().slideToggle(300); // clicking year slides months down }); $('#archiveList ul:eq(0)').show(); // make sure years stays visible </script>
  2. Add some more debug information to the ExecRequete function // Execution d'une requête SQL function ExecRequete($requete, $connexion){ $resultat = mssql_query($requete, $connexion) or echo('<p style="border:red 2px solid;padding:10px">DEBUG QUERY: <pre>' . $requete . '</pre></p>'); if($resultat){ return $resultat; } else{ echo "<b>Erreur dans l'execution de la requete '$requete' .</b>"; exit; } } // Fin de la fonction ExecRequete
  3. That is because you still have the form processing code in create.php. The form processing code in I am referring to are lines 192 to line 329. Cut and paste those lines into form_process.php replacing my example code. Once you have moved the code delete the following lines from form_process.php //Decide On What Path To Take SWITCH ($_GET['atgard']) { CASE "skapa": and break; DEFAULT: } Those lines are not needed.
  4. You want to see if the query returned any results using the mysqli_num_rows not mysqli_fetch_array function login($username , $password) { GLOBAL $dbc; // <--- BAD PROGRAMMING $user_id = user_id_from_username($username); $username = sanatize($username); $password = md5($password); $query = mysqli_query($dbc, "SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"); // check query return any results (results are returned as rows) // if we have a result then the login credentials matched if(mysqli_num_rows($dbc) > 0) { return true; } // no results found so return false return false; } Please use code tags when posting code. Press the <> button before pasting code into the reply box.
  5. Change if($end_time > 13){ to if($end_time >= 13){
  6. You wont be able to turn the image into a link, as images requested with <img /> the browser is expecting an image to be returned not html. But what you can do is check if the request for the image is from your site, by checking the HTTP_REFERER header. If it doesn't match serve a different image which will say something like "See my webcam at http://yourdomain.com". This is called anti image hot linking. Search google for this term and there be some php examples of this.
  7. Your code can be dramatically reduced, yes. Your doing a lot of code repetition. When you start to name variables like $var1, $var2, $var3 etc you should be using arrays. When you start to do repetitive code such as lines 26 to 113 you should be using loops. So if I want to list the numbers 1 to 1 million. Im not going to sit here and type all the numbers 1 to 1 million. I'm going to use a loop. for($i = 0; $i < 1000000; $i++) { echo "$i<br />"; } In 3 lines of code I have generated 1 million lines!
  8. Does contact.php contain PHP code? .load() will only return the output from this script, no PHP source code is returned. For example if contact.php had in it $myVar = 'abc'; And then in index.php you had echo $myVar; the variable $myVar will be undefined. PHP code will not be passed back to index.php If contact.php contains no PHP code then you are fine to use .load.
  9. @Barand your code remembers the selected checkbox. I think edfou also wants the chosen team option to be remembered too. I have modified Barand's code with JQuery which remembers the chosen gender and the corresponding team option <?php // if no form has been submitted then populate selectedOption array with no value $selectedOptionArray = ''; if(isset($_POST['btnsubmit'])) { $gender = $_POST['gender']; $key = $_POST['option']; // populates the javascript selectedOption array with the posted values (line 40) $selectedOptionArray = "'$gender', '$key'"; } ?> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> // when page has loaded change gender $(document).ready(function() { // list male/female team options here var teamOptions = { // male values and texts m: { 'm1' : 'aaa aaa', 'm2' : 'bbb', 'm3' : 'ccc' }, // female values and texts f: { 'f1' : 'xxx', 'f2' : 'yyy', 'f3' : 'zzz' } }; /* this will be populated by PHP. It'll used in changeOption to select the POST'd value selectedOptions[0] = the selected gender checkbox selectedOptions[1] = the selected option value */ var selectedOption = Array(<?php echo $selectedOptionArray; ?>); // function that populates the "option" select menu // selected gender is passed to this function function changeOption(gender) { // clear existing entries $('#option').html(''); // for each option for chosen gender $.each(teamOptions[gender], function(key, value) { // add option $('#option') .append($('<option>', { value : key }) .text(value)); }); // select the chosen option if( selectedOption.length > 0) { $('select[name="option"]').find('option[value="'+selectedOption[1]+'"]').attr("selected",true); } } // when page loads select the chosen option if(selectedOption.length > 0) changeOption(selectedOption[0]); // when the gender changes display new list $('input[name=gender]:radio').click(function() { changeOption(this.value); }); }); </script> </head> <body> <form action="" method="post"> <b>Gender</b><br /> <?php // builds checkboxes with php $genders = array( 'm' => 'Male', 'f' => 'Female'); foreach($genders as $value => $label): // check the checkbox that was checked when form was submitted // $checked is defined on line 6 $checked = (isset($gender) && $gender == $value) ? ' checked="checked"' : ''; ?> <input type="radio" name="gender" value="<?php echo $value ?>"<?php echo $checked; ?> /> <?php echo $label; ?><br> <?php endforeach ?> <br> <b>Team</b> <select name="option" id="option"> <option value="">- team options -</option> </select> <br><br> <input type="submit" name="btnsubmit" value="Submit"> </form> </body> </html>
  10. Can not use php to include contact.php? <?php include 'chapters/contact.php'; ?> Using PHP include will return the raw php source code of contact.php. The PHP code in contact.php will be parsed at the same time as index.php. If you use jquery $.load() function it'll only return the html source code of contact.php (the output).
  11. http://codex.wordpress.org/Category:WP-Cron_Functions
  12. What is looking for a file? You need to apply logic for your script for to do that.
  13. Okay. Post create.php and form_process.php here I will check it out
  14. Not sue if this article may help you http://tommcfarlin.com/wordpress-cron-jobs/
  15. You'd use mysqli_stmt_fetch() mysqli doesn't have mysqli_result.
  16. There is a trailing space after ENDHTML on line 22.
  17. When you perform queries on database you need to make sure they execute ok. During development you need to to output as much debug information as possible when something your expect to happen doesn't happen, if that makes sense. You said earlier when you use mysql_query it didn't work. So I recommended you add echo mysql_error to see if the query returns an error. You can remove the debug code when everything is working. So does your query return any errors when your run your script?
  18. Well you need to check if mysql_query is returning any errors $sql = "INSERT INTO com (name, lastname, email, coment) VALUES('$name', '$lastname', '$email','$coment')"; if(mysql_query($sql)) { echo "<script type='text/javascript'>alert('Thanks.'); window.close();</script>"; } else { echo 'Error: ' . mysql_error(); // I have commented out the line below. //echo"<script type='text/javascript'>alert ('$error'); window.close(); </script>"; }
  19. Because you're not doing anything with the query $result = "INSERT INTO com (name, lastname, email, coment) VALUES('$name', '$lastname', '$email','$coment')"; You have just defined a query to $result. PHP doesn't see it as a query, it just sees it as a string. What do you expect that line to do?
  20. No That is what makes the unix timestamp for the date you enter in the form by looks of things.
  21. Just trying to shred some more light on this $sql = 'SELECT distinct `field1`, ` field2` FROM `table1` partition (p1) Inner Join table2 On table1.id=table2.id Where table2.field1 = "something" And table2.field2 = " something_else"'; Is that a true representation of your query. with table names being substituted for fieldX and tableX Any reason for partition? As the alias p1 doesn't seem to be referenced anywhere in that query. Maybe posting the actual SQL query and dummy data will help further.
  22. If you want the modal to appear without the page reloading when the submit button is pressed you'll need to use ajax. PHP is ran on the server. Javascript is ran in the browser which is executed way after PHP has finished processing the script. You cannot send data to and from the server without the page reloading, unless you use ajax. If you implement my ajax method (just the javascript code) in post#13 to your code in post #6 (which I assume is create.php. and give the form an id of mailSetupForm)). and set the ajax request to create.php it should run as you expect, but the page will duplicate!. You only want the modal returned from the ajax request. This is happening because you process the form data from lines ~160 to ~280. You output the modal on line ~298. Any html/text outputted before that line will be sent back to the ajax request and this why the page duplicates. Moving the PHP code on lines 160 - 280 in create.php to form_process.php will prevent this from happening,as that file is only returning the html for the modal when the user has been added to the database not the entire page of create.php! form_process.php can be named to any thing just like any other php file you create. You just reference that file in the ajax request, like you would with any file you link to. Hope I have made it clearer now what I'm trying to get your to implement. if you're not happy with this then please say.
  23. no, that is where it is getting the raw data from the database (the 1262329261 value) and is storing the data in xml format. Somewhere else is another php file which processes this xml data. The line of code you're looking for is in this format $albumreleasedate = ... something here...; it may look: $albumreleasedate = date('jS F Y', ...somthing here with AlbumReleaseDate in it...);
  24. Ok. Ignore the ajax and modal for now, by commenting out the javascript. First lets make sure form_process.php is processing the data correctly. Modify your form so it just submits to form_process.php. When your fill in the form does form_process.php give any errors and is it doing what you want it to do. It should be adding the user to database and only showing the HTML for the modal.
  25. Its will be much bettee if you changed the date format where $albumreleasedate is defined. If your want to change the format of the date latter on this solution may not work.
×
×
  • 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.