Page 1 of 1
Help with insert function.
Posted: Tue Feb 22, 2005 11:40 am
by ludakuca
Here is what I try to do, if somebody can write me some kind of code to help me do this.
I have 8 games, people will bid on. There are 48 bidders, and they will bid on the games with win, draw or lose (1,x,2)
I have users table with their information as well as their username and password. So the table should look something like this.
http://www.tipliga.com/tipovi.php?kolo=16
So now, when they select what they want to tip on, they should click submit and the data shuold be stored in the table tips in the database.
My question is, what is the simplest way to implement this. I have visual made but nothing programmed, and it is really urgent for me.
Basically,
I should check the username and password from users table, and if incoredt post the data again, if correct submit the data into the tips table so I can manipulate it. Please if someone can write me some code to help me out with this I would appretiate.
Thanks
Posted: Tue Feb 22, 2005 11:42 am
by ludakuca
By the way this link is on different language, and I will probably use select statements.
Posted: Tue Feb 22, 2005 12:07 pm
by feyd
You can edit your posts here..
Are you sure you want someone to write it for you? If so, this thread will be moved.
Posted: Tue Feb 22, 2005 4:26 pm
by ludakuca
well this is what I was working on..
Right now, I have this script that checks the username and password writtem, and then....if true logs into the page where the tips are at and then sends the tips...
So I am fine now:)
Thanks, this is really poor solution so if somebody has something better please write is, so I can change it. Thanks.
OK so what am I doing wrong here??
Code: Select all
<?php
$thispage = 'login2.php';
$forwardpage = 'tipovi.php'; //SET THIS TO THE PAGE YOU USER WILL BE FORWARDED AFTER LOGIN/LOGOUT
//CHECK FOR LOGIN STATUS
$myid = $HTTP_COOKIE_VARSї"id_korisnika"];
$myusername = $HTTP_COOKIE_VARSї"korisnicko_ime"];
//IF LOGGED IN, SHOW USER ID
if ($action=="logout") {
setcookie("id_korisnika",$id_korisnika,time()-1,"/","www.tipliga.com",0);
setcookie("korisnicko_ime",$korisnicko_ime,time()-1,"/","www.tipliga.com",0);
?>
<<? echo "meta"; ?> <? echo"http-equiv";?>="refresh" content="3" Url="http://www.tipliga.com/tipovi.php">
Please wait while we log you out...
<?
} else {
if ($id_korisnika > "") {
/*------------------------------------------------------------
IF USER IS LOGGED IN, THEY SEE THE FOLLOWING
------------------------------------------------------------*/
echo "Your User ID is: $myid";
echo "<BR>Your Username is: $myusername";
?>
<BR><BR><a href="<? echo $thispage; ?>?action=logout&myid=<? echo $myid; ?>">Click Here to Logout</a>
<?
/*------------------------------------------------------------
END OF USER IS LOGGED IN
------------------------------------------------------------*/
} else {
//IF NOT LOGGED IN
if ($login == "") {
if ($myid == "") {
/*------------------------------------------------------------
IF USER IS NOT LOGGED IN, THEY SEE THE FOLLOWING LOGIN FORM
------------------------------------------------------------*/
?>
<FORM METHOD="POST" ACTION="<? echo $thispage ?>">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" ALIGN="CENTER">
<TR>
<TD ALIGN="CENTER">
</TD>
<TD ALIGN="LEFT">
<FONT FACE="ARIAL" SIZE="3">
<B> Login:</B>
</FONT>
</TD>
</TR>
<TR>
<TD><B><FONT SIZE="2" FACE="ARIAL">Username: </FONT></B></TD>
<TD><INPUT TYPE="TEXT" NAME="username" SIZE="12"></TD>
</TR>
<TR>
<TD><B><FONT SIZE="2" FACE="ARIAL">Password: </FONT></B></TD>
<TD><INPUT TYPE="password" NAME="password" SIZE="12"></TD>
</TR>
<TR>
<TD></TD>
<INPUT TYPE="HIDDEN" VALUE="yes" NAME="login">
<TD ALIGN="center"><INPUT TYPE="submit" VALUE="Login"></TD>
</TR>
</TABLE>
</CENTER>
</DIV>
</FORM><?
/*------------------------------------------------------------
END OF THE LOGIN FORM
------------------------------------------------------------*/
} //end if myid == nothing
} //END IF LOGIN == ""
if ($login == "yes") {
//CONNECTION STRING
include "dbconnect.php";
// $_GET VARIABLES
foreach($_GET as $a=>$b){$$a=$b; echo "<BR>$a: $b";}
// $_POST VARIABLES
foreach($_POST as $a=>$b){$$a=$b; echo "<BR>$a: $b";}
$sqllogin = "SELECT * FROM timovi WHERE korisnicko_ime = '$username' and sifra = '$password'";
$result = mysql_query($sqllogin);
if ($result > 1) {
if ($myrow = mysql_fetch_array($result)) {
do
{
$id_korisnika = $myrowї"id_korisnika"];
$korisnicko_ime = $myrowї"korisnicko_ime"];
setcookie("korisnicko_ime",$korisnicko_ime,time()+7200,"/","www.tipliga.com",0);
setcookie("id_korisnika",$id_korisnika,time()+7200,"/","www.tipliga.com",0);
echo "Welcome $korisnicko_ime! <br>
<BR>Please wait 2-3 seconds while we process your login...<BR>";
?>
<<? echo "meta ";?> <? echo"http-equiv";?>="refresh" content="3" Url="http://www.tipliga.com/tipovi.php">
<?
} while ($myrow = mysql_fetch_array($result));
} else {
echo "<P>That Username or Password was Not Found<p>";
?>
<a href="<? echo $thispage; ?>?">Click Here to Login</a>
<?
} //END IF MYROW RESULT
} else {
echo "No Results Returned";
} //END IF RESULT = 1
} //END IF LOGIN == YES
} //END IF NOT LOGGED IN.....
} //END IF NOT LOGGING OUT...
?>
example:
http://www.tipliga.com/login2.php
login with test as username and test as password. But when I try to logout, it does not wanna go to the page I want it to go.
When user logs in and logs out it should hit the page tipovi.php and it does not. WHat am I doing wrong?
Posted: Tue Feb 22, 2005 5:53 pm
by feyd
the cookie deletion code doesn't look right. Where are $id_korisnika and $korisnicko_ime coming from? The values used for deletion should be empty strings. The time used should be farther back in time, as 1 second ago could easily register as valid to the browser. I often recommend at least 1 week back, potentially more.
Your code seems to mix register_globals being on and not.. can you tell us which it is?
Code: Select all
<?php echo 'Register globals are ' . (ini_get('register_globals') ? 'on' : 'off'); ?>
Posted: Tue Feb 22, 2005 8:40 pm
by ludakuca
Globals are ON.
Posted: Tue Feb 22, 2005 8:58 pm
by feyd
and what of the answers to the other questions I asked?
Posted: Fri Feb 25, 2005 9:48 am
by ludakuca
Well, maybe because I did not quite understand what you were asking me for... Well I log in perfectly and It logs me out and clears the cookies, but the problem is with the redirect "meta refresh" it does not forward to the page I want, it just sits there saying please wait while we log you out...
What am I doing wrong?
Posted: Fri Feb 25, 2005 9:54 am
by feyd
meta-refresh syntax:
Code: Select all
<meta http-equiv="refresh" content="<seconds>ї; url=<url>]" />
where <seconds> is an integer for the number of seconds delay you wish to have, and <url> is an optional parameter of a URI.
http://webdesign.about.com/cs/metatags/a/aa080300a.htm
Posted: Fri Feb 25, 2005 10:04 am
by ludakuca
well the meta syntax is the same as for login, so redirects when I login, but it does not redirect when I log out..??
I dont get it.
Here is the code..
Code: Select all
<<? echo "meta ";?> <? echo"http-equiv";?>="refresh" content="3" Url="http://www.tipliga.com/tipovi.php">
Posted: Fri Feb 25, 2005 10:05 am
by feyd
your syntax does not match the specification.
Posted: Fri Feb 25, 2005 10:06 am
by ludakuca
I fixed it, I see where it was problem...
Thanks..