Jump to content
Larry Ullman's Book Forums

thara

Members
  • Posts

    54
  • Joined

  • Last visited

Everything posted by thara

  1. have you create a folder to move your file permanently in your server?? in this script its 'uploads' check weather it is exit or not...
  2. any body can help me to fix my problem... any comments are greatly appreciated...
  3. I used if ( isset( $_POST['city' ] ) ) { $city = $_POST['city' ]; } in my register.php page. but when Im trying to print the $city there is an error.
  4. thanks for your response. but Im not clear your answer larry.. Can I use findcity page's coding in my original register.php page.
  5. I am creating a registration form for my web site. In my registration form, there are two select boxes to select user's district and there city. So I need to do it, when a user select their district then automatically display city select box with cities which relevant to above selected district. To do this I used Ajax and php. I used findcity.php page to display the city in my register.php page. My problem is when I am try to get city id from the register.php page I cant get it. It I need to get to send with other data from register.php page to database. Please anybody help me to do it. and suggestions are greatly appreciated. thank you. from my register.php page <div> <label for="district">District <img src="../images/required_star.png" alt="required" /> : </label> <?php require_once ('../includes/config.inc.php'); require_once( MYSQL2 ); $query="select * from district order by district_id"; $result = mysqli_query( $dbc, $query); echo '<select name="district" class="text" onChange="getCity(' . "'" . 'findcity.php?district=' . "'" . '+this.value)">'; echo '<option value="">-- Select District --</option>'; while( $row = mysqli_fetch_array($result, MYSQLI_NUM)) { echo '<option value="' . $row[0] . '"'; // Check for stickyness: if ( isset( $_POST['district']) && ( $_POST['district'] == $row[0] )) echo ' selected="selected"'; echo " >$row[1]</option>"; } echo '</select>'; ?> </div> <div> <label for="city">City <img src="../images/required_star.png" alt="required" /> : </label> <input type="hidden" name="reg_locationid" id="reg_locationid" value="56" /> <div id="citydiv" style="position: relative; top: -14px; left: 130px; margin-bottom: -26px;"> <select name="city" class="text"> <option>-- Select City --</option> </select> </div> </div> this is findcity.php page <?php $districtId=$_GET['district']; require_once ('../includes/configaration.inc.php'); require_once( MYSQLCONNECTION ); $query="select city_id, city_name from city2 where district_id=$districtId"; $result=mysqli_query( $dbc, $query); echo '<select name="city" class="text"> <option>-- Select City --</option>'; while($row=mysqli_fetch_array($result, MYSQLI_NUM)) { echo '<option value="' . $row[0] . '"'; // Check for stickyness: if ( isset( $_POST['city']) && ( $_POST['city'] == $row[0] )) { echo ' selected="selected"'; //echo '<input type="hidden" name="city" value="' . $row[0] . '"'; } echo " >$row[1]</option>"; } echo '</select>'; this is my ajax functions function getXMLHTTP() { //fuction to return the xml http object var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getCity(strURL) { var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('citydiv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } }
  6. Thank you very much for your answers. ... Edward, this is a example of what I'm try to do... http://www.myprivatetutor.com/tutor_registration.php actually I'm trying to create such a registration form to my project. category table, subject table and category_subject table I have created. thanks for any comments.
  7. Thanks HartleySan for your answer. I tried to do according to your explanation. But still I could not to get my expecting result. page1.php page ok it display every category from my database. echo '<td width="50%"><input type="checkbox" name="category[]" value="' . $row['category_id'] . '" /> ' . $row['category_name'] . '</td>'; In my second page I need to display selected categories from 1st page and relevant subjects to that categories. eg: cat1 | sub1, sub2, sub3 cat2 | sub1, sub2, sub3, cat3 | sub1, sub4, sub5 and so on. every category has some subjects and all of those subjects should be display in my second page as category wise. subject also come from my subject table. category_subject table also available to make the relationship between every category and subject. In second page also working as I am expecting. above I have posted my second page coding. But my problem is 3rd page. In second page users can select 3 more subjects to 1 category. assume there is 3 category users can select 9 subjects. so my problem is how I bring those category and their subjects from 2nd page to my 3rd page. actually I am very confusing here and I try to do this for days. unfortunately still I cant get my expecting results. I waiting for any comments and those are greatly appreciated. thank you.
  8. any body can help me to fix my problem... any comments are greatly appreciated. thank you.
  9. Antonio, Thanks for your answer. I've been trying to do it according to your coding. still I am in the problem in 3rd form. I'm not sure where I want to go. Sorry. I am some confusing in multidimensional array. 1st and 2nd form working for me. but 3rd one is confusing. I am trying to get values to multidimensional array but I cant. my second form also dynamically generating according to 1st form categories which user selected. like this category1 subject1 subject2 subject3 category2 subject2 sbuject3 subject4 , like wise. in there, all subjects display relevant to that selected category. subjects also come from my subject table. this is the code I used to generate my second form if ( isset($_POST['submitted1']) && isset($_POST['category']) && ( sizeof( $_POST['category']) == 2 || sizeof( $_POST['category']) == 3 )) { foreach( $_POST['category'] as $value ) { $q = "SELECT * FROM category WHERE category_id = $value ORDER BY category_id" ; $r = mysqli_query( $dbc, $q); $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC); echo '<input type="radio" name="main_category[]" class="radio" value="' . $row['category_id'] . '" />'; echo '<label for="" class="radio"> ' . $row['category_name'] . ' <strong>: Mark this category as my "Main Category"</strong></label><br />'; $q = "SELECT category_subject.category_id, category_subject.subject_id, subjects FROM category_subject INNER JOIN category ON category_subject.category_id = category.category_id INNER JOIN subject ON category_subject.subject_id = subject.subject_id WHERE category_subject.category_id = {$row['category_id']}"; $result = mysqli_query( $dbc, $q); $c = $i = 0; echo '<table class="form_table" ><tr>'; while($row = mysqli_fetch_array( $result, MYSQLI_ASSOC )){ // if remainder is zero after 2 iterations (for 2 columns) and when $c > 0, end row and start a new row: if( ($c % 2) == 0 && $c != 0){ echo "</tr><tr>"; } echo '<td width="50%"><input type="checkbox" name="subject[]" value="' . $row['subject_id'] . '" /> ' . $row['subjects'] . '</td>' . "\n"; $c++; } // while.. // in case you need to fill a last empty cell: if ( ( $i % 2 ) != 0 ){ // str_repeat() will be handy when you want more than 2 columns echo str_repeat( "<td> </td>", ( 2 - ( $i % 2 ) ) ); } echo "</tr></table>"; } } Its work properly. Now I need to get category and only their selected subject to my 3rd form to display those values. actually I need to get their value as apiece. that mean category1 and their selected subject, category2 and their selected subjects and so on. I think solution should have a multidimensional array. I am very confusing there. Thanks
  10. Hello Everyone.. Im a programer in php with little experience. I have a form with 3 pages. 1st page display categories which come from category table. then user can select 1 or upto 3 category there. Then 2nd page display that selected categories and need to display relevant subject to that categories. In second page I use radio button for selected categories to keep a one category as a main category. each categories' subjects display with check boxes. In there too, user can select 1 or 3 more subject in to a particular category. In third form page, that my problem was encounter, there I need to print out selected category and their subjects in a table. first two pages are no problem for me and third form I have a problem in how to get categories and their subjects and they print as apiece in the page. like this category1 | subject1, subject2, subject3 category2 | subject1, subject2, subject3, subject and so forth. This same to my first form page $q = 'SELECT * FROM category ORDER BY category_id'; $r = mysqli_query( $dbc, $q); $c = 0; $i = 0; echo '<form action="subjects.php" method="post">'; echo '<table class="form_table" ><tr>'; while($row = mysqli_fetch_array( $r, MYSQLI_ASSOC )){ // if remainder is zero after 2 iterations (for 2 columns) and when $c > 0, end row and start a new row: if( ($c % 2) == 0 && $c != 0){ echo "</tr><tr>"; } echo '<td width="50%"><input type="checkbox" name="category[]" value="' . $row['category_id'] . '" /> ' . $row['category_name'] . '</td>'; $c++; } // while.. // in case you need to fill a last empty cell: if ( ( $i % 2 ) != 0 ){ // str_repeat() will be handy when you want more than 2 columns echo str_repeat( "<td> </td>", ( 2 - ( $i % 2 ) ) ); } echo "</tr></table>"; ?> In second page 'subjects.php' I use if ( isset($_POST['submitted1']) && isset($_POST['category']) && sizeof( $_POST['category']) == 3 ) { $_SESSION['category'] = $_POST['category']; print_r ( $_SESSION['category']); $q = 'SELECT * FROM category ORDER BY category_id'; $r = mysqli_query( $dbc, $q); while($_SESSION = mysqli_fetch_array( $r, MYSQLI_ASSOC )){ foreach( $_POST['category'] as $value ) { if ( $value == $_SESSION['category_id']) { $q = "SELECT category_subject.category_id, category_subject.subject_id, subjects FROM category_subject INNER JOIN category ON category_subject.category_id = category.category_id INNER JOIN subject ON category_subject.subject_id = subject.subject_id WHERE category_subject.category_id = {$_SESSION['category_id']}"; $r1 = mysqli_query( $dbc, $q); $c = $i = 0; echo '<table class="form_table" ><tr>'; while($_SESSION = mysqli_fetch_array( $r1, MYSQLI_ASSOC )){ // if remainder is zero after 2 iterations (for 2 columns) and when $c > 0, end row and start a new row: if( ($c % 2) == 0 && $c != 0){ echo "</tr><tr>"; } echo '<td width="50%"><input type="checkbox" name="subject[]" value="' . $_SESSION['subject_id'] . '" /> ' . $_SESSION['subjects'] . '</td>'; $c++; } // while.. // in case you need to fill a last empty cell: if ( ( $i % 2 ) != 0 ){ // str_repeat() will be handy when you want more than 2 columns echo str_repeat( "<td> </td>", ( 2 - ( $i % 2 ) ) ); } echo "</tr></table>"; } } } } Those two pages working properly. In third page that my problem page I tried something like this , but its not working. value come from subject.php page. if ( ( isset($_POST['submitted2'])) && ( isset($_SESSION['category'])) && (isset( $_SESSION['subjects'])) && sizeof( $_SESSION['category']) == 1) { //$_SESSION['category'] = $_POST['category']; print_r ( $_SESSION['category']); echo 'good'; } elseif ( ( isset($_POST['submitted2'])) && ( isset($_SESSION['category'])) && (isset( $_POST['main_category'] ))) { print_r ( $_SESSION ); echo 'very good'; } Note: I have started the sessions properly in every pages. So can any body tell me where is my mistake and help me fix this problem. any help greatly appreciated. thank you.
  11. Hello.. I have two php form and one has categories and their subjects. In there, users can select category and relevant subjects to that category. Likewise users can select upto 3 categories and their subjects in first form. when those select and after submitting those should handle in my second page. But I have made so frustrated here when Im going to handle those in my second page. Please Can anybody help me to do this. I use this, but...... if ( ( isset($_POST['submitted2'])) && ( isset($_SESSION['category'])) && (isset( $_SESSION['subjects'])) && sizeof( $_SESSION['category']) == 1) { //$_SESSION['category'] = $_POST['category']; print_r ( $_SESSION['category']); echo 'good'; } elseif ( ( isset($_POST['submitted2'])) && ( isset($_SESSION['category'])) && (isset( $_POST['main_category'] ))) { print_r ( $_SESSION ); echo 'very good'; } Thanks in advance.
  12. Here I use two php page with two forms. my first form is 'sign_up.php' and second is select_subject.php'. sign_up.php page has more categories and users can select up to 3 more categories there. So. after selecting and user click the continue bottom, page want to go to second form page its select_subject.php page. If a user not select a category of who selected over 3 category I need to display a error message. like this "Please select atleast 1, not more than 3 categories." I use this HTML my first page <form method="post" action="select_subject.php"> <my select boxes> </form> Then I process it in my second page and if user have made a mistake in first page I need to redirect to the first page again with relevant error message. So I use this code in my second page. } else { // No valid ID, kill the script. $_SESSION['errors'] = "Please select atleast 1, not more than 3 categories."; $url = 'http://localhost/lanka_institute/tutorsignup/tutor_registration.php'; // Define the URL: ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } and my first page I use this if (isset($_SESSION['errors'])) { echo '<p> ' . $_SESSION['errors'] . '</p>'; } unset($_SESSION['errors']); but it is not printing my error message in the first page that Im expecting. But it printing 'Array' instead of my message. can you help me, what is the mistake that I have done??? thanks in advance.
  13. Its still problem.. my first form is 'sign_up.php' and second is select_subject.php'. sign_up.php page has more categories and users can select up to 3 more categories there. So. after selecting and user click the continue bottom, page want to go to second form page its select_subject.php page. In there, i want to display the categories which user selected from sign_up.php page and also its provide to select subjects according to the categories they have selected. my problem is how can I check what are the categories user have selected and how they display in my second page. category come to first page from my category table. It has category_id and category_name columns. thanks for any help..
  14. Thanks Antonio Conte, But I couldn't understand exactly what have u said. can you tell me how this code work and why?? // Included wanted forms // If this is not allowed on server, use a switch/if-else foreach ( $forms as $key => $value ) { include('form'.$key.'.php'); }
  15. Hello.. I have Two HTML form and one is a Check boxes form that enable users to select their category. Then I need to display second form according to the categories they selected in first form. I use this code in first form to validate form submission.. if ( isset( $_POST['category']) && sizeof( $_POST['category']) <= 3) { $category = $_POST['category']; } else { $errors[] = 'Please select atleast 1, not more than 3 categories'; } If errors array is empty I did this.. if ( empty( $errors )) { // If everything's OK $_SESSION = $category; $url = 'http://localhost/lanka_institute/tutorsignup/select_subjects.php? // Define the URL. ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } Can I know and is this correct? I display category list from mysql category table, it has category name and category id this is my html part from first page echo '<td width="50%"><input type="checkbox" name="category[]" vlaue="' . $info['category_id'] . '" /> ' . $info['category_name'] . '</td>'; any help appreciated. Thanks in advance..
  16. Hi.. all I have a problem in my web site. There I have created a page call download.php and using it users can download song. I used a form to download button to display download box. after users click on download link i need to cancel it on that page. that mean I want to disappear it on download.php page. now when i click on browser's refresh button that download box still display on page. so any body can i help me to do it.. http://www.mist.lk/download.php?index=52 thanks in advance for any help....
  17. I have uploaded my music video in to the server and renamed it using songs id as larry teach in chapter 17. It work perfectly, but I retrieve the file in to the download script using their id, songs downloading without it's extension (mp3, wma ete), then users cant play them directly even if they downloaded the songs. so can I rename song's name again in my download script? I use songs id to find the upload file. upload file's name equal to the songs id. Thanks in advance for any help
  18. initialize that field to a value and then increment it by a value as you need when you insert next row to the database...
  19. Hi.. HartleySan, I have a another problem in my download page... i will post it as a new thread in the forum.. come back and help me.. ok
  20. Dear HartelySan, I tried simply adding a new field to the songs table used update query like this update `songs` set songCounter = songCounter +1 where songID = '$sid' It is work for me but it donsent mean down-loader actually finished the downloads ( it can cancel mid-way). Nevertheless my database table's fieldincrement by one. Is there any way to only count finish downloads.
  21. Thank you HartleySan your help.. Still I have a problem how can I count the downloaded in the database. can u tell me, should I need to create a separate table to manage downloaded users?
  22. No, dear, still im confusing that matter. can you tell me how can i create the database to count downloaded amount for a particular song? Hartley, Do you need to see my downloaded script?
  23. Ya, Hartley you are correct. I have created separate PHP script to handle audio/video songs. but I dont have any idea to do it in my download script. I have created a table called 'songs' to keep songs information, and there is a column named 'songs_name' to store songs name with it's extension. I dont sotore upload file's path in the database as well. thanks in advance for any ideas...
×
×
  • Create New...