is there a way to get user input into variables with php using only one file (ie have the form to input the data and process it in one document instead of "POST"ing to a seperate document)
Printable View
is there a way to get user input into variables with php using only one file (ie have the form to input the data and process it in one document instead of "POST"ing to a seperate document)
Yes?
I don't know the full rhetoric off the top of my head but it's a simple case of dealing with the $_POST superglobal. If there's nothing in it, user hasn't posted, otherwise do the usual cutting up into little bits and enjoy.
Sure. Just POST to yourself. In the document, check either if the request method is POST ($_SERVER['REQUEST_METHOD'] == 'POST') or if the variables are available (isset($_POST['whatever']). Do your processing depending on this.
But let me tell you, that's not pretty. Separating is better.
another thing im trying to stab at is this fancy mysql database output im trying to do if anyone thinks they could help (im new at php and mysql). Im trying to make my own automatied FAQ system. theres 4 fields for each row but thats not important
the problem is it only processes the first "while($row = mysql_fetch_array( $result ))" part correctly, the 2nd one doesnt do anything. if i switch them around in order the new first one works but not the 2nd one.Code:$result = mysql_query("SELECT * FROM faq");
if (!$result)
{
$errorreport="3faq printing out faq";
echo($errormessage);
}
else
{
$highestID=0;
$contentSize=0;
$contentPrinted=0;
while($row = mysql_fetch_array( $result ))
{
if($row['ID'] > $highestID)
{
$highestID=$row['ID'];
};
$contentSize=$contentSize+1;
}
echo($highestID);
while($row = mysql_fetch_array( $result ))
{
echo "<p>Question: ";
echo $row['Question'];
echo "<br>Answer: ";
echo $row['Answer'];
echo "</p><br>";
}
i think the problem is it doesn't look down through each row starting from the begining on the 2nd while loop, is there some kind of command to "reset" the "cursor"?
yeh i guess your right its alot easier to just seperate itQuote:
Originally Posted by CornedBee
Until someone more experienced answers, execute the query again. Perhaps if you just made the first one grab the "ID" field it wouldn't look so damn spaghettio. ;)Quote:
Originally Posted by MisterSako
EDIT: mysql_data_seek
I've got a database script using PHP/MySQL that manages customer information. So far it's about 1,500 lines so I'll just give you a zip link if you think it'll help.
Here's a preview:
http://bookmarkhosting.com/tool/
It is being worked on though so it's a WIP. Can't be much help to offer support, maybe it'll help you somehow. If not, I tried,
yes that i think would help alot please zip it up for me :}
thanks
One thing we use on the forum project I'm involved in is seperating data collection with display. So you would gather the information and store it and display it later. When large amounts of data is possible we use a call back function to get one part of it at a time. However its still seperated into the gathering and displaying part.
agh what am i doing wrong???
http://mrsako.gotdns.com/backupwithlogin.php
right below the body tag i tried to do this
<?php
include("loginsystem/include/session.php");
?>
why does it just write it all to the screen? on my faq section (scroll super alot down and click FAQ) i have php embded within my page there (but not a include file) and it works fine so i know i have PHP and mysql installed correcctly. this is whats in the session.php file
i tried putting php after <? but it just made the entire site not show up except for the include stuff
btw shadow if i'd still muchly appreciate that zip file :}PHP Code:
edit- i took this code out because it was a waste of 200 lines
Wow, you're that experienced with PHP that you're working with classes straight away? You need groupies, seriously. ;)
I think you'll find it's not optional. Please don't try that "Oh but it works... better!" argument.Quote:
Originally Posted by MisterSako
It's time you learnt the greatness that is PHP debugging, a.k.a. put echo "Ran to here"; statements EVERYWHERE!
nah i got it from here
http://evolt.org/node/60384
if someone else made what i need i dont think i should spend the time making my own :-p
i tried putting <?php where the guy put just <? but it seemed to not like doing that
i just foud ever <? and made it a <?php
im getting there :D
edit: i got this all figured out now, it turns out the author is a little bit of an idiot
i might end up not using his code itll probally just be brining me in the wrong direction
<? is allowed in place of <?php if short_open_tag has been enabled in php.ini
If it has not then you can not use it.
alright im stuck once again. i started all over and ditched that other guys login system
i have finished making my own system in which you can login and register
( http://mrsako.gotdns.com/index.php )
its pretty nifty you can even try it if youd like.
how it works lets say your logging in you type in the information on login.php and you hit submit and it gets processed in a different .php file. and then it sends you back to the site after logging you in. or it sends you back to login.php if you had a wrong username or password. what i want to do is be able to have some text coming up saying "invalid username or password" is there a way i can do this with variables by having the processing php file assign $errormsg="bad uname or pass"; then have login.php echo(errormsg);
or do i have to do something like login.php?error=1
im not going to use cookies though thats just dumb, id rather do the login.php?error=1 method