Page 1 of 1
PHP Self
Posted: Sat Dec 29, 2007 2:22 am
by kumarrana
I created a form for user. I know how to dump stuff in MySQL after user hits submit in an another page. But I have been trying to have everything in same page. Moreover I want to hide user form after user hit submit. Can anybody write a sample code, on how to process after user hits submit.
Posted: Sat Dec 29, 2007 2:55 am
by webspider
i think you can do this using an if-else condition
Code: Select all
<?php
if(isset($_POST['submit'])){
// dump stuff in mysql
}
else
{
//show the form to user
}
?>
Posted: Sat Dec 29, 2007 5:47 am
by staar2
Code: Select all
<form action="PageWhereUserGoesAfterSubmit.php" method="post"></form>
Re: PHP Self
Posted: Sat Dec 29, 2007 2:10 pm
by califdon
kumarrana wrote:I created a form for user. I know how to dump stuff in MySQL after user hits submit in an another page. But I have been trying to have everything in same page. Moreover I want to hide user form after user hit submit. Can anybody write a sample code, on how to process after user hits submit.
You are describing exactly what Ajax does. Using Javascript, and specifically the built-in Javascript class XMLHttpRequest (see
http://www.w3schools.com/xml/xml_http.asp), it fetches data from the server and makes it available to code in the same page, so you can remove unwanted document elements, insert new data, etc. Usually you do this using the HTML DOM property ".innerHTML", which every open/close tag HTML element has.
Posted: Sun Dec 30, 2007 1:09 am
by crystal ship
I don't think we need ajax here. The codes from webspider is enough to do the job.
PHP Self
Posted: Sun Dec 30, 2007 2:09 am
by kumarrana
With your help I went this far. I don't know much about Ajax so, I just sticked with what I know.
My problem is even after submit button it does nothing.
Code: Select all
<?php
echo "<form action=\"$PHP_SELF\" method=\"POST\">";
echo "Username:
<input name=username type=text>
<span class=style1>*</span>
<br> <br>
Password:
<input name=password type=password>
<span class=style1>*</span><br>
<br>
E-mail:
<input name=email type=text>
<span class=style1>*</span><br>
<br>
Name :
<input name=name type=text><br>
<input name=submit type=button value=Create Account>
</form>";
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$name = $_POST['name'];
echo " Do something $username";
echo "Do something";
}
?>
Posted: Sun Dec 30, 2007 2:37 am
by crystal ship
Code: Select all
<?php
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$name = $_POST['name'];
echo " Do something $username";
echo "Do something";
}else{
echo "<form action=\"$PHP_SELF\" method=\"POST\">";
echo "Username:
<input name=username type=text>
<span class=style1>*</span>
<br> <br>
Password:
<input name=password type=password>
<span class=style1>*</span><br>
<br>
E-mail:
<input name=email type=text>
<span class=style1>*</span><br>
<br>
Name :
<input name=name type=text><br>
<input name=submit type=submit value=Create Account>
</form>";
}
?>
Hope what you want is this...
Posted: Mon Dec 31, 2007 8:16 pm
by Jonah Bron
I believe there is a bit of vital information missing here
Info stated: everything must be done in the same page
Possible meaning: everything must be done without reloading the page
Is possible meaning true or false?
PHP Self
Posted: Tue Jan 01, 2008 4:41 am
by kumarrana
It worked perfect. Thanks a lot. Appreciate it;