Guest User

Untitled

a guest
Jun 22nd, 2018
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.95 KB | None | 0 0
  1. <?php
  2. $dbservertype='mysql';
  3. $servername='localhost';
  4. $dbusername='admin81';
  5. $dbpassword='admin81';
  6. $dbname='riz_new';
  7.  
  8. connecttodb($servername,$dbname,$dbusername,$dbpassword);
  9. function connecttodb($servername,$dbname,$dbuser,$dbpassword) {
  10. global $link;
  11. $link = mysql_connect ("$servername","$dbuser","$dbpassword");
  12. if (!$link) { die("Could not connect to MySQL"); }
  13. mysql_select_db("$dbname",$link) or die("could not open db".mysql_error());
  14. }
  15.  
  16. ?>
  17.  
  18. <!doctype html public "-//w3c//dtd html 3.2//en">
  19.  
  20. <html>
  21.  
  22. <head>
  23. <title>riz</title>
  24. <SCRIPT language=JavaScript>
  25. function reload(form) {
  26. enable();
  27. var val = form.cat.options[form.cat.options.selectedIndex].value;
  28. self.location = 'index.php?cat=' + val;
  29. }
  30. function reloadModel(form) {
  31. alert("b");
  32. var val = form.cat.options[form.cat.options.selectedIndex].value;
  33. var phoneModel = form.subcat.options[form.subcat.options.selectedIndex].value;
  34. self.location = 'index.php?cat=' + val + '&subcatModel=' + phoneModel ;
  35. }
  36. function enable() {
  37. // alert(document.f1.cat.options[document.f1.cat.options.selectedIndex].text);
  38.  
  39. if (document.f1.cat.options[document.f1.cat.options.selectedIndex].text == 'Select one') {
  40. document.getElementById("subcat").disabled = true;
  41. alert ("selected one");
  42.  
  43. }
  44. }
  45. window.onload=enable;
  46. alert("a");
  47. </script>
  48.  
  49.  
  50. <style type="text/css">
  51. select {height: 20px; width: 150px; max-height: 20px}
  52. input {height: 20px; width: 150px; max-height: 20px}
  53. </style>
  54.  
  55. </head>
  56.  
  57. <body>
  58.  
  59. <div style="position: absolute; left: 0; top: 0; right: 0; bottom: 0; ">
  60.  
  61. <div id="div1" style="width:50%; height:20%; background-color:White; border-style: solid; border-width: 1px; width: 50%; margin: auto;}" >a
  62.  
  63. <?
  64. @$cat=$_GET['cat']; // Use this line or below line if register_global is off
  65. if (strlen($cat) > 0 and !is_numeric($cat)) { // to check if $cat is numeric data or not.
  66. echo "Data Error";
  67. exit;
  68. }
  69.  
  70.  
  71. //@$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off
  72.  
  73.  
  74. $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category");
  75.  
  76. if (isset($cat) and strlen($cat) > 0){
  77. $quer = mysql_query("SELECT DISTINCT subcategory FROM subcategory where cat_id=$cat order by subcategory");
  78. } else {
  79. $quer = mysql_query("SELECT DISTINCT subcategory FROM subcategory order by subcategory"); }
  80.  
  81.  
  82. // Form begins
  83. echo "<form method=post name=f1 action='riz_next.php'>";
  84. /// Add your form processing page address to action in above line. Example action=dd-check.php////
  85.  
  86.  
  87. ////////// Starting of first drop downlist /////////
  88. // table begins
  89. echo "<table border='0'>";
  90.  
  91. echo "<tr>";
  92. echo "<td>Please select phone manufacturer</td>";
  93. echo "<td>";
  94. echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
  95. while($noticia2 = mysql_fetch_array($quer2)) {
  96. if ($noticia2['cat_id'] == @$cat){
  97. echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<br>";}
  98. else {
  99. echo "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";
  100. }
  101. }
  102. echo "</select>";
  103. echo "</td>";
  104. echo "</tr>";
  105. echo "<tr>";
  106. echo "<td>Service Provider of Phone</td>";
  107. echo "<td>";
  108. echo "<select id = 'subcat' name='subcat' onchange=\"reloadModel(this.form)\" ><option value=''>";
  109. echo $_GET["subcatModel"];
  110. echo "test";
  111. echo "</option>";
  112. while($noticia = mysql_fetch_array($quer)) {
  113. echo "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>";
  114. }
  115. echo "</select>";
  116. echo "</td>";
  117. echo "</tr>";
  118. echo "<tr>";
  119. echo "<td>Phone Model</td>";
  120. echo "<td>";
  121. echo "<input id = 'model' type='text' name='model'>";
  122. echo "</td>";
  123.  
  124. echo "</tr>";
  125. echo "<tr>";
  126. echo "<td>IMEI Number</td>";
  127. echo "<td>";
  128. echo "<input id = 'imei' type='text' name='imei'>";
  129. echo "</td>";
  130.  
  131. echo "</tr>";
  132.  
  133. echo "</table>";
  134.  
  135. // Submit
  136. echo "<input type=submit value=Submit>";
  137. echo "</form>";
  138.  
  139. ?>
  140. </div>
  141.  
  142. <div id="div2" style="width:50%; height:80%; background-color:wheat; border-style: solid; border-width: 1px; width: 50%;
  143. margin: auto; text-align: center;">
  144.  
  145.  
  146. <?php
  147. $result = "Select Phone model";
  148. if($_GET["subcatModel"] == "iPhone 3G"){
  149. $result = "Youve selected 1";
  150. }
  151.  
  152. ?>
  153.  
  154. Price: <?php echo $result; ?><br>
  155. Process Time: <br>
  156.  
  157. </div>
  158.  
  159. </div>
  160. </body>
  161.  
  162. </html>
Add Comment
Please, Sign In to add comment