kevdotbadger
-
Posts
18 -
Joined
-
Last visited
Never
Posts posted by kevdotbadger
-
-
Hello, im using Jquery to preform some AJAX calls. Now i know that not all people have javascript turned on. I need to know how to determine whether the page is being called directly (typing in the url), or indirectly (XMLHttpRequest).
Is there any way of doing this?
-
no no no. Thats all fine.
I think the problem lies in
if($x == 1){
$q4 = "'{$Value}'";
}else{
$q4 = "'{$Value}',";
}
Now what i want to do is change the else branch so that the $q4 is an array and each time it loops around the loop it adds to the array.
Any ideas?
-
I made a simple function to dymanically create a SQL query.
<?php function AddDataToTable(){ $HowMany = func_get_arg(0); $x = func_get_arg(0); $TableName = func_get_arg(1); $q1 = "INSERT INTO $TableName ("; while($HowMany > 0){ $Name = func_get_arg($HowMany + $HowMany); $Value = func_get_arg($HowMany + $HowMany + 1); $q2 = ''; if($x == 1){ $q2 = "'$Name'"; }else{ $q2 = "'$Name',"; } $HowMany = $HowMany - 1; } $q3 = ")values("; $HowMany = func_get_arg(0); while($HowMany > 0){ $Name = func_get_arg($HowMany + $HowMany); $Value = func_get_arg($HowMany + $HowMany + 1); $q4 = ''; if($x == 1){ $q4 = "'{$Value}'"; }else{ $q4 = "'{$Value}',"; } $HowMany = $HowMany - 1; } $q5 = ")"; echo $q1.$q2.$q3.$q4.$q5; };
Now when i run the function with...
AddDataToTable(4, name_table, name, kevin, age, 19, email, hhh, address, myhouse);
the output displays
INSERT INTO name_table ('name',)values('kevin',)
It doesnt display the other values.
Any idea why? And how i would output all the values?
-
Hello, im writing a simple script which html is entered into a form, the ata is prcessed and it returns the formatted code, with htmlentries removed and replaced with there text equvilent.
<html>
<head>
<title>Upload</title>
</head>
<body>
<?php
$posttext = $_POST['code'];
$posttext_remove_crap = htmlspecialchars($posttext);
if(isset($posttext)){
echo "<div style='padding: 10px; border: 1px solid black; display: block; width: 900px;'>";
echo $posttext_remove_crap;
echo "</div>";
};
?>
<form action="convert.php" method="POST">
<textarea name="code" rows="100" cols="100"></textarea>
<input type="submit" value="Go">
</body>
</html>
so far the html removal works. But its all returned in one line and the format is gone (white space, paragraph space etc)
how would i go about keeping the format when the string is echoed? -
can someone remove this please! i jsut LIMITED th mysql query! easy as pie!
-
right i have a mysql query which 'selects all fields from 'features' order by 'id' desc'
that works fine and everything and i have a while loop which keepes looping and gets all data and echos it.
how would i go about getting and disaplying only 3 sets of data as opposided to all the data?
so instead of ID1, ID2, ID3.......ID44, ID45. i jsut print out the last 3, i.e ID43, ID44, ID45.
would i need to do a different loop? -
[quote author=mgallforever link=topic=112564.msg456928#msg456928 date=1161715562]
or if you arent using mysql for this
[code]
<?php
$pass = thepassyouwant;
$user = theuseryouwant;
$password = $_POST[password];
$username= $_POST[username];
if($password == $pass && $username == $user){
echo "login right";
setcookie("login","yes",time()+3600);
}else{
echo "wrong login";
};
?>
[/code]
then for pages that require login
[code]
<?php
if($_COOKIE[login] == yes){
echo "stuff you want them to see";
}else{
echo "not logged in or bad auth";
};
?>
[/code]
[/quote]
after reading through this (which is basically exactly the same i sussed it!
i forgot the ; after the end of the loop!
thanks! solved ALL my problems!
@mgallforever: yeah i think ill set it now! -
[quote author=thorpe link=topic=112564.msg456926#msg456926 date=1161715466]
[quote]now can someone explain why it just ignores setcookie[/quote]
Can you explain what it is that makes you think it is ignoring setcookie. Its in both cases of the expression, so one of them MUST be firing.
[/quote]
well i created another page which echos the value of the cookie. both times (after loggin in incorrectly and logging in correctly) they both say that the cookie value is nothing. -
Probably nothing but its bugging me how its not working!
basically a username and password has been send from a form. the values have been catched and wrote into a varialbe. These are matched against 2 pre-defined varialbes. If they match i want to set a cookie, if they dont i want to delete the cookie.
heres my code.
[code=php:0]<?php
$username = "user";
$password = md5("pass");
$try_username = $_POST['username'];
$try_password = md5($_POST['password']);
if(($username == $try_username) && ($password == $try_password)){
setcookie("login", "true", time()+3600);
echo "login correct";
}else{
setcookie("login", "", time()-3600);
echo "login incorrect";
}
?>[/code]
now can someone explain why it just ignores setcookie -
i use the automatated scripts within dreamweaver, the login on works but th rscrit access doesnt so is thre tuts on the internet to handcode this?
-
$LoginRS__query=sprintf("SELECT name, password FROM fantasyf1_users WHERE name='%s' AND password='%s'",
Change to;
$LoginRS__query=sprintf("SELECT name, password FROM fantasyf1_users WHERE name='$user_name' AND password='$password'",
also you might want to encrypt the data too
so use this
$LoginRS__query=sprintf("SELECT name, password FROM fantasyf1_users WHERE name='%user_name' AND password=PASSWORD('%password')",
Dont use the second script intill you are sure everyone can log on and stuff.
You have NO idea how many problems im having with the logging in and stuff.
-
I made a simple news update system a few nights ago using dreamweaver.
I had a few problems with logging in but all is fine now, or is it?Well it isnt. It seems that once i have logged (whic forwards to broswer to the admin;php page, from here i have links to add_news.php, update_news.php and delete_new.php) when i go to the "add_new.php" page is seems to bring this error up.
Notice: A session had already been started - ignoring session_start() in c:\program files\easyphp1-8\www\news update\add_news.php on line 25
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\news update\add_news.php:25) in c:\program files\easyphp1-8\www\news update\add_news.php on line 63
Right line 25 shows;
<?php session_start(); $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "failed.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?>
AND
Lines 63 shows;
[/code]
header("Location: ". $MM_restrictGoTo);
The whole page code is; [CODE] <?php require_once('Connections/news_update.php'); ?> <?php //initialize the session session_start(); // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles session_unregister('MM_Username'); session_unregister('MM_UserGroup'); $logoutGoTo = "logout.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php session_start(); $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "failed.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_news")) { $insertSQL = sprintf("INSERT INTO newsarticle (title, news, `user`, `date`) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['title'], "text"), GetSQLValueString($_POST['message'], "text"), GetSQLValueString($_POST['name'], "text"), GetSQLValueString($_POST['date'], "text")); mysql_select_db($database_news_update, $news_update); $Result1 = mysql_query($insertSQL, $news_update) or die(mysql_error()); $insertGoTo = "news_admin.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_news_update, $news_update); $query_add_nes = "SELECT * FROM newsarticle"; $add_nes = mysql_query($query_add_nes, $news_update) or die(mysql_error()); $row_add_nes = mysql_fetch_assoc($add_nes); $totalRows_add_nes = mysql_num_rows($add_nes); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>add news</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); //--> </script> <link href="font.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <table border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="600" height="28" valign="top"></td> </tr> <tr> <td width="600" height="89" valign="top" background="img/logo.gif"> </td> </tr> <tr> <td width="600" height="32" valign="top" class="font"><div align="right"><a href="<?php echo $logoutAction ?>">Log out</a> </div></td> </tr> <tr> <td width="600" height="230" valign="top"><p class="font">Fill in the form below to add news to the news.php page. <br> <br> </p> <form action="<?php echo $editFormAction; ?>" method="POST" name="add_news" id="add_news"> <div align="left"> <p align="right"><span class="font">Name <input name="name" type="text" id="name"> <br> <br> Title <input name="title" type="text" id="title"> <br> <br> Message <input name="message" type="text" id="message"> <br> <br> Date <input name="date" type="text" id="date" align="middle"> <br> <br> </span> <input name="Submit" type="submit" class="font" value="add news"> </p> </div> <input type="hidden" name="MM_insert" value="add_news"> </form> <p class="font"> </p></td> </tr> <tr> <td width="600" height="30" valign="top"> </td> </tr> <tr> <td width="600" height="1" valign="top"><img src="transparent.gif" alt="" width="600" height="1"></td> </tr> </table> </body> </html> <?php mysql_free_result($add_nes); ?>
Any ideas?
Where can i find
in MySQL Help
Posted
mysql-standard-5.0.26-osx10.4-i686.dmg
and
mysql-5.0.26.tar.gz
Anyone?