Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i go about echoing back to a form from a form post action?
    primarykey
    data
    text
    <p>I have a form containing a textarea for inputing text into. The form also contains a submit button. After pressing the submit button it posts the text within the textarea into my php document. Within my php document the text is added to a database. Once it has been added to the database I would like it to echo back a response telling the user that it has added the text to the database successfully. However, if i make it echo that response back to the home page, there is nowhere declared for it to display the echoed message. Has anyone got an idea of what i should be doing in order to get this working? Many Thanks.</p> <p>Normally i wouldn't use a post straight from the form and i would use ajax and then display the data within a paragraph or something on it's return, however since the form is doing the post it's self i am not sure where to then declare where the response should show up. </p> <p>The bellow displays my html form code and shows it's action to post to a php file.</p> <pre><code> &lt;div id="userban2"&gt;&lt;form id="bannable" action="/onlineusers.php" method="post"&gt;&lt;p&gt; Type username to ban bellow:&lt;/p&gt; &lt;textarea name="banned" id="banned" maxlength="255"&gt;&lt;/textarea&gt;&lt;br/&gt; &lt;input type="submit" value="Send" class="extrabuttons" onclick="return false; preventDefault();"&gt; &lt;div id="cancelban" class="extrabuttons"&gt;&lt;p&gt; cancel&lt;/p&gt;&lt;/div&gt; &lt;/form&gt; </code></pre> <p>However when in my php file i write ....</p> <pre><code> echo "the information has been added to the database successfully"; </code></pre> <p>It might send the echo back however it isn't declared to display anywhere how can i change this to make it display the response within my form?</p> <p>As requested return from my php</p> <pre><code>if(isset($_POST["banned"])){ $ban_name = $_POST["banned"]; bannedd($ban_name); } function bannedd($ban_name) { $query1 = mysql_query("INSERT INTO banned_users (username,firstname,lastname,email,password,ip_address,sign_up_date,last_logged_in,about,sta rr,userpref) VALUES('$usernameb','$fnameb','$lnameb','$emailb','$passwordb','$ip_addressb','$sign_up_date b','$last_logged_inb','$aboutb','$starrb','$userprefb')") or die("Could not insert your informaion"); echo "This user has successfully been banned"; } </code></pre> <p>The form posts what is written in the form due to it having the action and method of post to my php. However should i then have any return i am not sure how i declare where the returned information should then show (The echoed message).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload