Autor Zpráva
Silver8000
Profil
Ahoj vsem mam problem s formularem ktery vytvarim pro registraci Admina po instalaci DB.
Formular se po odeslani neodesila.

Prosim o pomoc vyreseni problemu.

<?php
$date = date("d/m/Y");
$form4 = <<<FORM4
<html>
<head>
<style type="text/css">
body{
    background-color: #464646;
    color: white;
}

#passwordAlert{
    color: red;
    margin:5px;
    display:none;
    text-align:center;
    background-color:#464646;
    padding:5px;
}
</style>
<script type="text/javascript">

function check_password() {

        var p1 = document.getElementById("password1").value;
        var p2 = document.getElementById("password2").value;


        if(p1.length>5) {
            document.getElementById("passwordAlert").style.display = 'none';

            if(p1===p2){
                document.getElementById("passwordAlert").style.display = 'block';
                validpass="yes";
                document.getElementById("passwordAlert").innerHTML = '<input type="submit" name="create_login" id="create_login" value="Create login" />';
            } else {
                validpass="no";
                document.getElementById("passwordAlert").style.display = 'block';
                document.getElementById("passwordAlert").innerHTML = "Passwords must match.";
            }

        } else{
            document.getElementById("passwordAlert").style.display = 'block';
            document.getElementById("passwordAlert").innerHTML = "Password must be at least 6 characters.";
        }

}

        // called when mouse over
        function mouseOverListenerFunc(o){
            o.type = "text";
        }
        // called when mouse out
        function mouseOutListenerFunc(o){
            o.type = "password";
        }
</script>
</head>

<body>
<div align="center">
<h1>Create Admin Login</h1>
<hr style="width: 100%; height: 2px;"><br>
<h2>Please insert your login details.</h2>
<h3>Move mouse over to show passwords.</h3>
<form enctype="text/plain" method="post" action="aindex.php?step=4" name="create_admin_login">
  <table style="text-align: left;" border="0" cellpadding="0" cellspacing="5">
    <tbody>
      <tr>
        <td>User name *</td>
        <td> : </td>
        <td><input name="user_name" value="" /></td>
      </tr>
      <tr>
        <td>User password *</td>
        <td> : </td>
        <td><input name="user_password" value="" id="password1" type="password" maxlength="20" onkeyup="check_password()" onmouseover="mouseOverListenerFunc(this)" onmouseout="mouseOutListenerFunc(this)" />
        </td>
      </tr>
      <tr>
        <td>User password verify *</td>
        <td> : </td>
        <td><input name="user_password_verify" value="" id="password2" type="password" maxlength="20" onkeyup="check_password()" onmouseover="mouseOverListenerFunc(this)" onmouseout="mouseOutListenerFunc(this)" />
        </td>
      </tr>
      <tr>
        <td>User email *</td>
        <td> : </td>
        <td><input name="user_email" value="" /><input name="user_registration" value="$date" type="hidden" /></td>
      </tr>
      <tr>
        <td>* required field<br />User name and Passwords<br />minimum length 6 characters.</td>
        <td></td>
        <td align="right"><div id="passwordAlert"></div>
        </td>
      </tr>
    </tbody>
  </table>
</form>
<hr style="width: 100%; height: 2px;"></div>
</body>
</html>
FORM4;
echo $form4;
?>

Moderátor Davex: Titulek „HTML FORM Problem“ nevystihoval podstatu dotazu. Příště zkus prosím vymyslet lepší.
Joker
Profil
Silver8000:
Prosím o popis problému.
Silver8000
Profil
Joker:
Takze formular funguje nasledovne :
uzivatel cili v tomto pripade Admin vyplni formular Uzivatelskym jmenem
Heslem ktery se overuje a pokud je heslo overeno a spravne zobrazi se tlacitko k odeslani,po vyplneni administracniho emailu se muze formular odeslat a tady je prave kamen urazu ten formular se odesle ale ne spusobem jaky zrovna chci.

mam teto formular v souboru aindex.php pro testovani
v souboru mam definici podminky:

<?php

//toto je jen pro zacatek abych s tim mohl dale pracovat
//po odeslani formulare se nic neodesle a timpadem se neprovede funkce print_r($_POST);

if($_POST){
print_r($_POST);
}else{
echo $form4;
}
?>
peta
Profil
Silver8000:

Moderátor Joker: Odmazal jsem návod na zkopírování celého kódu stránky sem do diskuse.
Nekopírujte do diskuse celý kód stránky, kromě výjimečných případů, kdy je celý kód opravdu nezbytný k řešení problému.

Pripadne to vlozit na jsfiddle.net (6, 7, 8, 9) a sem dat odkaz na kod. Ja se nechystam tvuj php kod prekladat do html.
Nebo hledas chybu v php kodu? Moc dotazu nerozumim. Vlastne, tazaci veta ma na konci otaznik, ve tvem prispevku takova veta neni, prispevek je tedy oznamovaci. Dekujeme, ze jsi nam to sdelil, ze mas problem.

Kazdopadne, muzes pred radek 2 vlozit print_r($_POST);, pokud formular odesila na tu samou stranku, tak ti tam zobrazi vsechny poslane hodnoty. Pripadne to dej do souboru na ktery odesilas formular a hned za to muzes dat die();, aby zastavil zbytek programu, jako treba presmerovani pres header(); na jinou stranku.
Pokud se to neodesle vubec, tak mas chybu asi v javascriptu, nevim, nekoukal jsem, co tam provadi js.
Kdyz tak koukam na konec, nechybi ti tam input type=submit, odesilaci tlacitko?
Silver8000
Profil
No takze se to potvrdilo ze je chyba nekde v javascriptu ja jsem si to take myslel,udelal jsem co jsi rekl s tim printem a nic se vubec neodesila.
Tak te prosim o mensi upravu jelikoz nevim vubec jak dal,ten java jsem poskladal z netu..tzv. co se hodilo do kramu. :-D
<html>
<head>
<style type="text/css">
body{
    background-color: #464646;
    color: white;
}
 
#passwordAlert{
    color: red;
    margin:5px;
    display:none;
    text-align:center;
    background-color:#464646;
    padding:5px;
}
</style>
<script type="text/javascript">
 
function check_password() {
 
        var p1 = document.getElementById("password1").value;
        var p2 = document.getElementById("password2").value;
 
 
        if(p1.length>5) {
            document.getElementById("passwordAlert").style.display = 'none';
 
            if(p1===p2){
                document.getElementById("passwordAlert").style.display = 'block';
                validpass="yes";
                document.getElementById("passwordAlert").innerHTML = '<input type="submit" name="create_login" id="create_login" value="Create login" />';
            } else {
                validpass="no";
                document.getElementById("passwordAlert").style.display = 'block';
                document.getElementById("passwordAlert").innerHTML = "Passwords must match.";
            }
 
        } else{
            document.getElementById("passwordAlert").style.display = 'block';
            document.getElementById("passwordAlert").innerHTML = "Password must be at least 6 characters.";
        }
 
}
 
        // called when mouse over
        function mouseOverListenerFunc(o){
            o.type = "text";
        }
        // called when mouse out
        function mouseOutListenerFunc(o){
            o.type = "password";
        }
</script>
</head>
 
<body>
<div align="center">
<h1>Create Admin Login</h1>
<hr style="width: 100%; height: 2px;"><br>
<h2>Please insert your login details.</h2>
<h3>Move mouse over to show passwords.</h3>
<form enctype="text/plain" method="post" action="aindex.php?step=4" name="create_admin_login">
  <table style="text-align: left;" border="0" cellpadding="0" cellspacing="5">
    <tbody>
      <tr>
        <td>User name *</td>
        <td> : </td>
        <td><input name="user_name" value="" /></td>
      </tr>
      <tr>
        <td>User password *</td>
        <td> : </td>
        <td><input name="user_password" value="" id="password1" type="password" maxlength="20" onkeyup="check_password()" onmouseover="mouseOverListenerFunc(this)" onmouseout="mouseOutListenerFunc(this)" />
        </td>
      </tr>
      <tr>
        <td>User password verify *</td>
        <td> : </td>
        <td><input name="user_password_verify" value="" id="password2" type="password" maxlength="20" onkeyup="check_password()" onmouseover="mouseOverListenerFunc(this)" onmouseout="mouseOutListenerFunc(this)" />
        </td>
      </tr>
      <tr>
        <td>User email *</td>
        <td> : </td>
        <td><input name="user_email" value="" /><input name="user_registration" value="$date" type="hidden" /></td>
      </tr>
      <tr>
        <td>* required field<br />User name and Passwords<br />minimum length 6 characters.</td>
        <td></td>
        <td align="right"><div id="passwordAlert"></div>
        </td>
      </tr>
    </tbody>
  </table>
</form>
<hr style="width: 100%; height: 2px;"></div>
</body>
</html>


Edit : No tak jsem zjistil ze bez JS to taky neodesila hodnoty,to uz fakt nevim v cem je chyba
Mimochodem mam to na localhostu
Silver8000
Profil
Tak jsem to opravil sam nakonec
Joker
Profil
Silver8000:
Tak jsem to opravil sam nakonec
A čím to bylo?
Davex
Profil
Joker:
A čím to bylo?
Tipoval bych to na přebytečný atribut enctype="text/plain" ve formuláři.

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0