Autor | Zpráva | ||
---|---|---|---|
ja duck Profil |
#1 · Zasláno: 2. 10. 2015, 12:19:12
Dobry den všem,
jsem začátečník, ale chci dát kamaradovi k narozeninam tento dárek, ale nedaří se mě ho dodělat. Jedná se o větší formulař. Prosím o pomoc s PHP a Javascriptem. Mělo by to kontrolovat povinné pole a pote odeslani. Měl bych ještě prosbu - nevím jak udělat kontrolu proti "spam"-u . Přikládám část kodu. Prosím Vás o pomoc. Předem děkuji Will <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <?php $mandatory = array("email" => "Email", "mobil" => "Mobil", "title" => "Title", "first_name" => "First Name", "surname" => "Surname", "number" => "Number", "street" => "Street", "city" => "City", "postcode" => "Postcode", "card" => "Membership Card", "number_card" => "Number Card", "price_from" => "Price From", "price_up_to" => "Price up To"); function nevyplnene($mandatory) { $unfilled = array(); foreach ($mandatory as $key => $val) { if (!$_POST[$key]) { $unfilled[] = $val; } } return $unfilled; } if (isset($_POST["sent"])) { $unfilled = unfilled($mandatory); if (!$unfilled) { mysql_query("INSERT INTO user (email, mobil, title, first_name, surname, number, street, city, postcode, card, number_card, price_from, price_up_to) VALUES ('" . mysql_real_escape_string($_POST["email"]) . "', '" . mysql_real_escape_string($_POST["mobil"]) . "', '" . mysql_real_escape_string($_POST["title"]) . "', '" . mysql_real_escape_string($_POST["first_name"]) . "', '" . mysql_real_escape_string($_POST["surname"]) . "', '" . mysql_real_escape_string($_POST["number"]) . "', '" . mysql_real_escape_string($_POST["street"]) . "', '" . mysql_real_escape_string($_POST["city"]) . "', '" . mysql_real_escape_string($_POST["postcode"]) . "', '" . mysql_real_escape_string($_POST["card"]) . "', '" . mysql_real_escape_string($_POST["number_card"]) . "', '" . mysql_real_escape_string($_POST["price_from"]) . "', '" . mysql_real_escape_string($_POST["price_up_to"]) . "')"); echo "Your question has been sended!"; } else { echo "<p>Unlisted item: " . implode(", ", $unfilled) . "</p>\n"; } } ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1252"> <title>Form new computer</title> <style> body {background: url("seda.gif"); background-repeat: repeat-x; background-color: #353535;} #nadpis {position: absolute; top: 79px; left: 454px;} .leva {position: absolute; top: 251px; left: 20px; color: #0000A1; border: dotted #0000A1 3px; width: 218px; height: 14px; background: #FFD2ED; padding: 10px; font: bold 15px Arial; color: #FF0049;} .leva img {position: absolute; top: 33px; left: -4px;} .prava {position: absolute; top: 251px; right: 10px; color: #0000A1; border: dotted #0000A1 3px; width: 218px; height: 14px; background: #FFD2ED; padding: 10px; font: bold 15px Arial; color: #FF0049;} .prava img {position: absolute; top: 33px; left: -57px;} /** Formular **/ form {position: absolute; top: 112px; left: 321px; border: ridge #00E900 12px; width: 680px; height: 837px; padding: 8px; background: #FFF796;} input {font: 14px Arial; color: #0D0808; border: solid #000000 2px;} select {border: solid #000000 2px;} #osudaje label {letter-spacing: 0.6pt;} #osudaje {border: ridge #582A00 6px; width: 627px; height: 302px; margin-left: 22px; background: #97FFE6; font: 16px Aharoni; color: #00008E;} </style> </head> <body><br> <img src="nadpis.gif" id="nadpis" width="444" height="24"> <div class="leva"> <h4 style="position: relative; top:-23px;"> There are mandatory details!!! </h4><br> <img src="lsipka.gif" width="300px" height="24px"> </div> <div class="prava"> <h4 style="position: relative; top:-23px;"> There are mandatory details!!! </h4> <img src="psipka.gif" width="300px" height="24px"> </div> <script type="text/javascript"> function checkFields(frm) { for (i=1; i < arguments.length; i++) { if (frm[arguments[i]].value == '') { frm[arguments[i]].focus(); alert('Please fill in all required fields !'); return false; } } return true; } </script> <form action="" method="post" onsubmit="'<?php echo implode("', '", array_keys($mandatory)); ?>');"> <input type="hidden" name="sent" value="1" /> <div id="osudaje"> <!-- email + mobil --> <label style="position: relative; top: 7px; left: 8px;" for="email"> Email: </label> <input style="position: relative; top: 7px; left: 9px;" type="text" size="24" id="email" name="email" /> <label style="position: relative; top: 7px; left: 178px;" for="mobil"> Mobil: </label> <input style="position: relative;top: 7px; left: 180px;" type="text" size="12" id="mobil" name="mobil" /> <!-- jmeno --> <label style="position: relative; top: 38px; left: -331px;" for="title">Title:</label><br /> <select style="position: relative; top: 38px; left: 54px;" id="title" name="title"> <option> </option> <option> Mr </option> <option> Mrs </option> <option> Ms </option> <option> Miss </option> </select><br /> <label style="position: relative; top: 1px; left: 211px;" for="first_name"> First Name: </label><br /> <input style="position: relative; top: 1px; left: 185px;" type="text" size="18" id="first_name" name="first_name" /> <label style="position: relative; top: -21px; left: 294px;" for="surname"> Surname: </label><br /> <input style="position: relative;top: -21px; left: 398px;" type="text" size="22" id="surname" name="surname" /><br> <!-- bydliste --> <label style="position: relative; top: 14px; left: 31px;" for="number"> Number: </label><br /> <input style="position: relative; top: 14px; left: 25px;" type="text" size="8" id="number" name="number" /> <label style="position: relative; top: -8px; left: 117px;" for="street"> Street: </label><br /> <input style="position: relative; top: -8px; left: 129px;" type="text" size="27" id="street" name="street" /> <label style="position: relative; top: -30px; left: 208px;" for="city"> City: </label><br /> <input style="position: relative; top: -30px; left: 350px;" type="text" size="19" id="city" name="city" /> <label style="position: relative; top: -52px; left: 371px;" for="postcode"> Postcode: </label><br /> <input style="position: relative; top: -52px; left: 521px;" type="text" size="8" id="postcode" name="postcode" /> <label style="position: relative; top: -2px; left: -60px;" for="card">You have "Membership Card" ?</label><br /> <select style="position: relative; top: -2px; left: 118px;" id="card" name="card"> <option> </option> <option> Yes </option> <option> No </option> </select><br /> <label style="position: relative; top: -40px; left: 358px;" for="number_card"> If yes, write the Number Card: </label><br /> <input style="position: relative; top: -40px; left: 430px;" type="text" size="11" id="number_card" name="number_card" /> ....... |
||
ja duck Profil |
#2 · Zasláno: 3. 10. 2015, 14:28:40
Nevím v čem muže být chyba. Poradí mě někdo??
|
||
mimochodec Profil |
#3 · Zasláno: 3. 10. 2015, 14:42:36
Dělá to přesně co? Přes ten isset na 17. řádku to projde? Přes if (!$unfilled) to projde?
|
||
ja duck Profil |
#4 · Zasláno: 3. 10. 2015, 18:45:48
mimochodec:
Nevým zda-li mě něco chybí, ale jak si to zobrazím na prohlížeči /GOOGLE/, tak mám kod napsaný ve stránce. Poradíš? |
||
Tomáš123 Profil |
#5 · Zasláno: 3. 10. 2015, 20:44:41
ja duck:
Začni štúdiom na péhapku. Hneď druhá kapitola základného kurzu ťa naučí, čo je potrebné pre spustenie PHP kódu. Google je vyhľadávač. |
||
mimochodec Profil |
#6 · Zasláno: 4. 10. 2015, 00:43:07
ja duck:
„jak si to zobrazím na prohlížeči /GOOGLE/“ Zdá se mi, že myslíš google chrome. A taky se mi zdá, že tohle php máš buď v html souboru, nebo je to někde (na lokálu?), kde php nefunguje. |
||
Časová prodleva: 9 let
|
0