Skocz do zawartości

Zdjęcie
- - - - -

Przechwytywanie danych formularza


4 odpowiedzi w tym temacie
  • Zaloguj się, aby dodać odpowiedź
webmazz

    Nowy użytkownik

  • 19 postów
    • Czas spędzony online: 1d 2h 21m
-1
Neutralna

Napisano 14 października 2015 - 07:38

#1

W jaki sposób przechwycić część danych z formularza i jeżeli są poprawne to wysłać całość?

Chodzi o to, że mam pola takie jak: imie, nazwa użytkownika, hasło, lokalizacja oraz zdjęcie profilowe.
Chcę, aby skrypt sprawdzał poprawność danych osobowych i jeżeli są one poprawne to wysyłał formularz w tle, a dopiero później zdjęcie. Chodzi o to, aby wszystko działo się bez przeładowania strony.

Najgorsze jest to, że muszą zostać wysłane tak jakby dwa formularze i nie mogę tego ogarnąć.


Użytkownik webmazz edytował ten post 14 października 2015 - 07:39

  • 0

zonic

    WT Elite

  • 2 911 postów
    • Czas spędzony online: 134d 2h 28m 23s
472
Znakomita!
  • LocationToruń

Napisano 14 października 2015 - 08:02

#2

W jaki sposób przechwycić część danych z formularza i jeżeli są poprawne to wysłać całość?

Chodzi o to, że mam pola takie jak: imie, nazwa użytkownika, hasło, lokalizacja oraz zdjęcie profilowe.
Chcę, aby skrypt sprawdzał poprawność danych osobowych i jeżeli są one poprawne to wysyłał formularz w tle, a dopiero później zdjęcie. Chodzi o to, aby wszystko działo się bez przeładowania strony.

Najgorsze jest to, że muszą zostać wysłane tak jakby dwa formularze i nie mogę tego ogarnąć.

Pokaż, co teraz masz


  • 0

webmazz

    Nowy użytkownik

  • 19 postów
    • Czas spędzony online: 1d 2h 21m
-1
Neutralna

Napisano 14 października 2015 - 08:16

#3

Pokaż, co teraz masz

window.MVC.Controllers.PageRegistration.prototype.signup = function (formData) {

    if (!this.validateForm(formData)) {
        Notifications.setHeadline('');
        Notifications.setText(Labels.getLabel('Login_ValidateFailed'));
        Notifications.show();

    } else {
        Preloader.show();
        $passwordHash = CryptoJS.SHA256(formData.password);
        $password = $passwordHash.toString(CryptoJS.enc.Hex);
        var payload = { "username": formData.username,
            "password": $password,
            "email": formData.email,
            "phone": formData.phone,
            "fullname": formData.fullname,
            "lat": formData.lat,
            "lng": formData.lng,
            "address": formData.address
        };

        window.Autobahn.call("pl.biokod.users", "signup", payload,
            function(success, response) {
                Preloader.hide();
                if (success) {
                    Notifications.setHeadline('Rejestracja');
                    Notifications.setText("Zostałeś pomyślnie zarejestrowany.");
                    Notifications.show();
                    window.location.href = PageRoutes.getRoute('login');

                } else {
                    Notifications.setHeadline('Błąd rejestracji');
                    Notifications.setText(response.message);
                    Notifications.show();
                }
            }
        );
    }
};
window.MVC.Views.Registration.prototype.render = function (argFormat) {

    if (argFormat == 'html') {

        this.htmlString = [];
        this.htmlString.push('<section id="registration" class="panel colors_black_semitransp">');
        this.htmlString.push(' <div class="header">');
        this.htmlString.push('  <div class="image"><img></img></div>');
        this.htmlString.push('  <div class="label"><h2>Rejestracja</h2></div>');
        this.htmlString.push(' </div>');
        this.htmlString.push(' <div class="form">');
        this.htmlString.push('  <form id="form_registration" name="form_registration" action="" method="POST" enctype="multipart/form-data" autocomplete="off">');
        this.htmlString.push('   <input type="text" class="login" name="username" placeholder="Nazwa użytkownika"><br/>');
        this.htmlString.push('   <input type="text" class="firstname" name="fullname" placeholder="Imię i nazwisko"><br/>');
        this.htmlString.push('   <input type="text" id="geocomplete" class="address" name="address" placeholder="Domyślna lokalizacja"><br/>');
        this.htmlString.push('   <input type="hidden" class="lat" name="lat" placeholder="Szerokość geograficzna">');
        this.htmlString.push('   <input type="hidden" class="lng" name="lng" placeholder="Długość geograficzna">');
        this.htmlString.push('   <input type="text" class="phone" name="phone" placeholder="Numer telefonu"><br/>');
        this.htmlString.push('   <input type="text" class="email" name="email" placeholder="Adres email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"><br/>');
        this.htmlString.push('   <input type="password" class="password" name="password" placeholder="Hasło" pattern=".{6,}"><br/>');
        this.htmlString.push('   <input type="password" class="retype_password" name="retype_password" placeholder="Powtórz hasło" pattern=".{6,}"><br/>');
        this.htmlString.push('   <input type="file" class="profile_photo" name="profile_photo"><br/>');
        this.htmlString.push('   <input type="checkbox" class="personal_data_consent" name="personal_data_consent" value="0">' + Labels.getLabel('Registration_DataProcessingConsent') + '<br/>')
        this.htmlString.push('   <input type="submit" class="submit" name="submit" value="' + Labels.getLabel('Registration_SubmitLabel') + '">');
        this.htmlString.push('  </form>');
        this.htmlString.push(' </div>');
        this.htmlString.push(' <div class="actions">');
        this.htmlString.push('  <div class="text">' + Labels.getLabel('Actions_HaveAccount') + '<a href="' + PageRoutes.getRoute('login') + '">' + Labels.getLabel('Actions_LoginNow') + '</a></div>');
        this.htmlString.push('  <div class="text">' + Labels.getLabel('Actions_ForgotPassword') + '<a href="' + PageRoutes.getRoute('password_recovery') + '">' + Labels.getLabel('Actions_RecoverPassword') + '</a></div>');
        this.htmlString.push(' </div>');
        this.htmlString.push(' <div class="legal_info">' + Labels.getLabel('Registration_LegalInfo') + '</div>');
        this.htmlString.push('</section>');

        return this.htmlString.join(NEW_LINE).toString();
    }

};

Do zdjęcia ma być

method: `add_profile_photo`

  • 0

webmazz

    Nowy użytkownik

  • 19 postów
    • Czas spędzony online: 1d 2h 21m
-1
Neutralna

Napisano 14 października 2015 - 11:04

#4
Można zamknąć:)
  • 0

Yeoman

    Stary wyjadacz

  • 358 postów
    • Czas spędzony online: 6d 19h 43m 48s
169
Znakomita!
  • LocationKatowice

Napisano 14 października 2015 - 17:02

#5

Ale burdel


  • 1

2ed58r7.png






Podone tematy Collapse

Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych