PHP Formular mit MySQL

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • PHP Formular mit MySQL

    Hi mal wieder ihr lieben...

    Ich suche ein Script eine Art Formular.
    Und zwar wo User sich eintragen können ohne Anmeldung

    mit 2 oder 3 Fenster

    Name:
    Wohnort:
    Hobby:

    das soll dann in die Datenbank geschrieben werden und die soll es alphabetisch nach Namen sotieren. Und das soll dann wiederrum in auf einer andere seite ausgegeben werden wo sie sotiert sind

    Ich danke euch
  • schon ok hänge bloss gerade hier

    wo bestimme ich das das script sich im top öffnet also an
    der spitze
    es versetzt sich nämlich immer ein stück nach unten

    Quellcode

    1. <?
    2. #################################################
    3. # xLinks 2002 #
    4. #################################################
    5. # © by Robert Klikics | http://x-dev.de #
    6. # eMail: rob@x-dev.de #
    7. #################################################
    8. # License: GPL #
    9. # please don't remove this copyright - thx #
    10. #################################################
    11. # FILE: view.php #
    12. #################################################
    13. // die if !$cat
    14. if(!$cat) die("<h4>Script says: \"I need a category to show!!!\" ");
    15. #======================================================================#
    16. # the includes & mySQL-conn
    17. #======================================================================#
    18. require("./inc/conf.inc.php"); // cfg
    19. require("./inc/connect.php"); // mySQL
    20. require("./lang/$language"); // language-file
    21. include("./inc/head.inc"); // header
    22. //set table-vars
    23. $table_linkdata = $db_prefix."linkdata";
    24. $table_cat = $db_prefix."cat";
    25. $table_votes = $db_prefix."votes";
    26. $table_languages = $db_prefix."languages";
    27. //Connect to mySQL
    28. $conn = @MYSQL_CONNECT($server, $user, $pass);
    29. //Select DB
    30. @MYSQL_SELECT_DB($mydb) or die ("<h1>Database '$mydb' does not exist or mySQL is not connected!<p>Please check your settings ...</h1>");
    31. //Check
    32. if(!$conn) die("<h1>mySQL-Connection-Error<br>Check your settings ...</h1>");
    33. #======================================================================#
    34. # add vote to db & check if already voted
    35. #======================================================================#
    36. if($yourvote)
    37. {
    38. //save vote in db
    39. $sql = "INSERT INTO $table_votes (vote, link_id, cat)";
    40. $sql.= "VALUES ('$yourvote', '$id', '$cat')";
    41. MYSQL_QUERY($sql);
    42. //vote counter +1
    43. MYSQL_QUERY("UPDATE $table_linkdata SET hp_votes = hp_votes + 1 WHERE id = $id");
    44. // generate actual vote-count and put into "LINKDATA-->hp_votes"
    45. $result = MYSQL_QUERY("SELECT vote FROM $table_votes WHERE link_id = $id");
    46. $anzahl = MYSQL_NUM_ROWS($result);
    47. while ($row = MYSQL_FETCH_ARRAY($result)) { $allvotes = $allvotes + $row[vote]; } // summary of votes for an id
    48. if($anzahl == 1) $allvotes = $yourvote; // set $allvotes to 1, if it's the first one
    49. $av_votes = round($allvotes / $anzahl, 1); // get & round the average-votes
    50. // put $av_votes to db
    51. MYSQL_QUERY("UPDATE $table_linkdata SET hp_vote = $av_votes WHERE id = $id");
    52. // show auto-link if vote added
    53. echo <<<end_xx
    54. <meta http-equiv="refresh" content="2; URL=$PHP_SELF?cat=$cat&s=$s">
    55. <table width="100%" border="0" cellspacing="3" cellpadding="3" height="95%">
    56. <tr valign="middle" align="center">
    57. <td>
    58. end_xx;
    59. echo "\n<font size='2'>".VIEW_VOTE_AUTOLINK."</b>\n";
    60. echo "<p>[ <a href='$PHP_SELF?cat=$cat&s=$s'>link</a> ]";
    61. echo <<<end_x
    62. </td>
    63. </tr>
    64. </table>
    65. </body>
    66. </html>
    67. end_x;
    68. exit;
    69. } // endif $yourvote
    70. #======================================================================#
    71. # get data from db by right order ...
    72. #======================================================================#
    73. if(($cat) && (!$yourvote))
    74. {
    75. if($sort == "new" || $incatsort == "id") { $incatsort = "id"; $sortby = "DESC"; $act_sort = VIEW_SORTING_NEW; } // sorting by old/new
    76. if($sort == "old") { $incatsort = "id"; $sortby = "ASC"; $act_sort = VIEW_SORTING_OLD; }
    77. if($sort == "vote" || $incatsort == "hp_vote") { $incatsort = "hp_vote"; $sortby = "DESC"; $act_sort = VIEW_SORT_BY_VOTE; } //sort by rating
    78. if($sort == "hits" || $incatsort == "hp_votes") { $incatsort = "Hits"; $sortby = "DESC"; $act_sort = VIEW_SORT_BY_HITS; } //sort by hits
    79. if($sort == "name" || $incatsort == "name") { $incatsort = "name"; $sortby = "ASC"; $act_sort = VIEW_SORTING_NAME; } //sort by name
    80. //when searching
    81. if($cat == "search") {
    82. $result = MYSQL_QUERY("SELECT * FROM $table_linkdata WHERE name LIKE \"%$q%\" order by $incatsort $sortby LIMIT 0,$max_search "); // get seach-query's to $max_search
    83. $scnt = MYSQL_NUM_ROWS($result);
    84. } else {
    85. if(!$s) { $showfrom = 0; $datasets = $perpage; // params for default--output (on 1 page)
    86. } else {
    87. $showfrom = $s; $datasets = $perpage; } // set params for page--output (multiple pages)
    88. // get total number of links in a cat
    89. $countz = MYSQL_QUERY("SELECT COUNT(id) FROM $table_linkdata WHERE cat = $cat ");
    90. $anz = MYSQL_RESULT($countz,0);
    91. MYSQL_FREE_RESULT($countz); //mem
    92. $result = MYSQL_QUERY("SELECT * FROM $table_linkdata WHERE cat = $cat order by $incatsort $sortby LIMIT $showfrom,$datasets "); //get linkdata
    93. } //endif $search
    94. #======================================================================#
    95. # javascript for jump-menu
    96. #======================================================================#
    97. ?>
    98. <script language='javascript'>
    99. <!--
    100. // jump-menu
    101. function jumper(targ,selObj,restore)
    102. {
    103. eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    104. if (restore) selObj.selectedIndex=0;
    105. }
    106. //-->
    107. </script>
    108. <p>
    109. <table width="100%" border="0" cellspacing="3" cellpadding="3" height="95%">
    110. <tr valign="middle" align="center">
    111. <td>
    112. <table border='0' cellspacing='1' cellpadding='1' align='center' width='<?=$linkwidth?>'>
    113. <tr>
    114. <td align='center'>
    115. <?
    116. #======================================================================#
    117. # render cat-info & some NAVI-links
    118. #======================================================================#
    119. if($cat != "search") //show not if searching
    120. {
    121. $hello = MYSQL_QUERY("SELECT * FROM $table_cat WHERE id = $cat"); // get cat-info
    122. $world = MYSQL_FETCH_ARRAY($hello);
    123. echo "\n\n<!-- powered by xLinks [ © http://x-dev.de - get it there ] -->\n\n";
    124. echo "</td>\n</tr>\n";
    125. MYSQL_FREE_RESULT($hello); // give memory free
    126. } else {
    127. echo "<h4>$listname | ".SEARCH_RESULTS." $q ($max_search max.)</h4>\n"; } // print search-resluts header
    128. #======================================================================#
    129. # render output-table for each link
    130. #======================================================================#
    131. if(!$scnt && $cat == "search") echo SEARCH_NO_RESULTS; // msg if no search-results found
    132. //function to generate the <select>-field for 'vote'
    133. function VoteSelect()
    134. {
    135. global $PHP_SELF;
    136. global $cat;
    137. global $row;
    138. global $s;
    139. // <select> for vote
    140. echo "\t<select name='a_vote' onchange=\"jumper('self',this,0)\">\n";
    141. echo "\t<option>".VIEW_VOTE_SELECT."\n";
    142. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=1'>1 - ".VIEW_BADDEST_VOTE."\n";
    143. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=2'>2\n";
    144. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=3'>3\n";
    145. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=4'>4\n";
    146. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=5'>5\n";
    147. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=6'>6\n";
    148. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=7'>7\n";
    149. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=8'>8\n";
    150. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=9'>9\n";
    151. echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=10'>10 - ".VIEW_BEST_VOTE."\n";
    152. echo "\t</select>\n";
    153. }
    154. while ($row = MYSQL_FETCH_ARRAY($result))
    155. {
    156. // get date of posting and format as set
    157. if($timeformat == 1) $pd = strftime("%d.%m.%Y", $row[poster_time]);
    158. elseif($timeformat == 2) $pd = strftime("%A, %d-%m-%Y %R", $row[poster_time]);
    159. elseif($timeformat == 3) $pd = strftime("%d-%m-%Y", $row[poster_time]);
    160. else $pd = strftime("%Y-%d-%m", $row[poster_time]);
    161. //strip-slashes
    162. if($html == "ON")
    163. {
    164. $row[hp_desc] = stripslashes($row[hp_desc]);
    165. $row[name] = stripslashes($row[name]);
    166. $row[url] = stripslashes($row[url]);
    167. $row[poster_name] = stripslashes($row[poster_name]);
    168. $row[poster_email] = stripslashes($row[poster_email]);
    169. }
    170. // include design.inc.php and render table's
    171. include("inc/design.inc.php");
    172. }
    173. MYSQL_FREE_RESULT($result); // give memory free
    174. } //endif $cat
    175. ?>
    176. <br>
    177. <table border='0' align='center' width='<?=$linkwidth?>'>
    178. <tr>
    179. <td align='right'>
    180. <?
    181. // <select> for catjump
    182. $sweet = MYSQL_QUERY("SELECT * FROM $table_cat order by $catorder");
    183. while ($cats = MYSQL_FETCH_ARRAY($sweet))
    184. {
    185. if($cats[id] != $cat) echo "<option value='$PHP_SELF?cat=$cats[id]&sort=$sort'>$cats[name]\n"; // render cat-selection
    186. }
    187. MYSQL_FREE_RESULT($sweet); // give memory free
    188. echo "</select>\n";
    189. ?>
    190. </td>
    191. </tr>
    192. </table>
    193. <br>
    194. <table border='0' align='center' width='<?=$linkwidth?>'>
    195. <tr>
    196. <td align='center'>
    197. <?
    198. #======================================================================#
    199. # navigation @ page bottom of the cat-view
    200. # (only if not searching)
    201. #======================================================================#
    202. if($cat != "search")
    203. {
    204. //var's
    205. $ges = $anz / $perpage;
    206. if(is_integer($ges)) $pgcnt = $ges;
    207. else $pgcnt = $ges + 1; // get page-counter in a cat
    208. //$lastpg = $anz - $perpage; // $s of last page
    209. $actpg = $s / $perpage + 1; // get number of actual page
    210. $sh_to = $showfrom + $perpage; // $s for next page
    211. $sh_strt = $showfrom - $perpage; // $s for prev. page
    212. if($sh_to > $anz) $sh_to = $anz; // ---- "" ----
    213. if($sort) $linkvar = "&sort=$sort"; // string for sorting if set
    214. } //endif $q
    215. // HTML:
    216. ?>
    217. </td>
    218. </tr>
    219. </table>
    220. </td>
    221. </tr>
    222. </table>
    223. <?
    224. #======================================================================#
    225. # footer &
    226. # END OF FILE
    227. #======================================================================#
    228. // PLEASE DONT CHANGE THIS [for dev]
    229. #################################################################################################################
    230. echo "\n<!-- some copyright, please don't remove :: thank you [ http://x-dev.de ] -->\n"; #
    231. echo "\n<p align='center'>&copy; <a href='jump.php?id=x' target='_blank'>xLinks</a> 2002\n"; # #
    232. //disconnect from mySQL #
    233. MYSQL_CLOSE(); #
    234. #################################################################################################################
    235. include("./inc/foot.inc");
    236. ?>
    Alles anzeigen