Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Jack

Pages: [1]
1
Your a genius!!!!!!!!!!!!!!!!!!!!!!!!!! thnx

2
Basically I need to display everything I query from the DB in reverse Order, I tried using arsort but heck that didnt work. (It a small forum application and I want the new threads to be first )

HELP ME :-\



PHP Code: [Select]


function AddField$assoc$column$style 
{
  echo 
' <td class= "'$style '">'$assoc[$column] . "</td>\n";
}




PHP Code: [Select]
<?php

//echo '<body>';


$connect Connect_to_db("forumVars.inc"); 
$query "SELECT Thread.*, date, author
FROM Thread, post
WHERE
parent_topic =" 
$_GET['topicID'] . " AND
parent_thread = Thread.id AND
in_reply_to IS NULL"
;

$result mysqli_query$connect$query );

if (
$result == 0)
{
echo 
"<b>Error: ";
echo 
mysqli_error($cxn)."</b>";
}
else 
#28
{
echo 
"<table width=\"100%\"
class=\"forumline \"cellpadding=\"25\""
;
echo 
" cellspacing=\"1\" border=\"0\" align=\"center\">";
echo 
"<tbody>";
DisplayThreadsHeader();// heading for threads
for( $i 0$i mysqli_num_rows$result ); $i++ )

{
  
$thread mysqli_fetch_assoc$result );

echo 
"<tr>\n";
echo 
"<center>";
echo 
'<td class="threadSubject">'
echo 
'<a href="viewThread.php?threadID='.$thread['id'] . '">';
echo 
$thread['subject'];
echo 
"<hr />";
echo 
'</a>';
echo 
" </td>\n";
echo 
" <center>";
AddField$thread"replies""threadFiller" ); 
AddField$thread"author""threadFiller" );
AddField$thread"last_post""threadFiller" );
echo 
" </center>";
echo 
"</tr>\n";

}

echo 
"</tbody></table>";
echo 
'<b><a href="postMessage.php?topicID='.
$_GET['topicID']. '">';
echo 
"<center><big>Ask A question</big></center></a></b>";

}
?>

3
Beginners - Learning PHP / implementing next and previous(FORUM)
« on: May 07, 2012, 05:53:48 AM »
Well I basically just need a code snippet or advice. I have a forum that retrieves comments and posts from an sql database problem is, it show all comments and posts on One page. (which can become very long ) How can i divide it into say 10 posts per page?--- and implement next and previous to go about viewing?

4
Its obvious what this should do,,, if i press button A it should display the message in A and so on but it doesnt work,, This is more or less the same code from a textbook whats wrong with the code

//page.inc
<html>
<body>
<form action = "<?php print $_SERVER['PHP_SELF']?>">

<input type ="submit" name  ="Button" value = "A"/>

<input type ="submit" name  ="Button" value = "B"/>


<?php print "$mess" ?>

<?php print $_POST['Button'] ?>
</form>
</body>
</html>


----------------------------------------------------------------------------------------------------------------------------------


//Code.php
<?php
session_start();
switch(@$_POST['Button'])
{
#######################################
case "A":

$mess = "you have pressed A";

include ("Page.inc");
break;

######################################
case "B":

$mess = "you have pressed B";

include ("Page.inc");
break;

########################################

default:
$mess = "you have pressed C";
include ("Page.inc");
}
?>

5
General PHP Help / Multple Login System
« on: March 06, 2012, 12:15:41 AM »
Hello, Im experimenting with login systems (php & mysql)
can anyone help me or refrence me with code that will allow for multiple users to login at the same time.

6
Hello

Im using XAMPP 1.7.4 beta 2 to test my applications. When I connect to mysql (which came with the XAMPP) using the mysqli_connect function it works because it does not display an error message from the or die("not connecting") function

 But when i try to query the database and insert values it does absolutely nothing. The other problem I have is that I cant create a database with the mysql that came with XAMPP because i do not have privileges over mysql. and i cant set the privileges because i donnt know the master passord and user name aaaaaah I know the default passwor is "" and username is "root" but it doesnt work.

but what confuses the hell out of me is that when i add a database to Mysql localhost mysql doesnt show the database when i type in the show databases command  but i can connect to it but not query it? what the hell,,,,

is the beta version the problem?
can you send me code for a connection test?
can someone explain to me how i can install mysql  so that xampp will still connect to that sql ?
or any help will be good.

7
This is line 172

PHP Code: [Select]
[b]$sql="INSERT INTO Member (loginName,CreateDate,password,lastname,firstname,street,city,state,ZIP,Email,phone,fax)VALUES
('
$loginName',NOW(),md5('$password'),'$lastName','$firstName','$street','$city','$state','$ZIP','$email','$phone','$fax')";[/b]

8
I have been thinking about this error for two days now I cant sleep I cant eat , AAAAAH why? help meee!! please!!!

(Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\JAck\Login_reg.php on line 172)

PHP Code: [Select]
<?php
/*Program: Login_reg.php
*Desc: Main application script for user login
*This application provides two options:
*(1)Login using existing username and
*(2)Register a new user
*/

Session_Start();
switch(@
$_POST['button'])
{
Case 
" Log in":
Include(
"dogs.inc");
$cxn =mysqli_connect($host,$user,$password,$database)
or die (
"Could not connect to database");
$sql "SELECT loginName from member
where loginName = '
$_POST [fusername]'";
$result mysqli_query ($cxn,$sql)
or die (
"Query died: fusername");
$num mysqli_num_rows($result);
if (
$num 0// LOGIN NAME WAS FOUND
{
$sql "SELECT loginName FROM member
where loginName ='
$_POST[fusername]'
AND password = md5('
$_POST[fpassword]')";
$result2 mysqli_query($cxn,$sql)
or die (
"qquery died: fpassword");
$num2 mysqli_num_rows($result2);
if(
$num2 0// password matchess
{
$_SESSION['auth'] ="yes";
$_SESSION['logName'] = $_POST ['fusername'];
$sql "INSERT INTO Login (loginName,LoginTime)
VALUES('
$_SESSION[logname]',NOW())";
$result mysqli_query($cxn,$sql)
or die (
"query died: insert");
header("location: SecretPage.php");

}
else
{
$message_1 ="the login name,'$_POST[fusername]' already exists";
$fusername strip_tags(trim($_POST['fusername']));
include(
"login_form.inc");
}
}
else 
//login name not found
{
$message_1 ="The user Name you have entered does not exist! Please try again.";
include (
"login_form.inc");
}
break;

Case 
"Register":
/*Check for blanks */
foreach ($_POST as $field => $value)
{
if (
$field != "fax")
{
if (empty(
$value))
{
$blanks[] = $field;
}
else 
{
$good_data[$field] = strip_tags(trim($value));
}
}
}
if(isset(
$blanks))
{
$message_2 "THE FOLLOWING FIELDS ARE BLANK.";
foreach(
$blank as $value)
{
$message_2 .="value, ";
}
extract ($good_data);
include (
"login_form.inc");
exit();
}
/* Validate Data */
foreach($_POST as $field => $value)
{
if (!empty(
$value))
{
if(
preg_match("/name/i",$field)and
!
preg_match("/user/i",$field)and
!
preg_match("/log/i",$field))
{
if (!
preg_match("/^[A-za-z' -]{1,50}$/",$value))
{
$errors[] = "$value is not a valid name.";
}
}
if(
preg_match("/street/i",$field)or
preg_match("/addr/i",$field)or
preg_match("/city/i",$field))
{
if(!
preg_match("/ ^ [A-Za-z0-9.,'  -]{1.50}$/"$value))
{
$errors[] = "$value is not a valid address or city.";
}
}
if(
preg_match("/state/i",$field))
{
if(!
preg_match("/^[A-Z][A-Z]$/",$value))
{
$errors[] = "$value is not valid state code.";
}
}
if(
preg_match("/email/i",$field))
{
if(!
preg_match("/^.+@.+\\. . +$/",value))
{
$errors[] = "$value  is not a valid email addr.";
}
}
if (
preg_match("/zip/i",$field))
{
if(!
preg_match("/^[0-9]{5}(\-[0-9]{4})?$/",
$value))
{
$errors[] = "$value is not a valid zipcode.";
}
}
if(
preg_match("/phone/i",$field )or
preg_match("/fax/i",$field))
{
if ( !
preg_match("/^[0-9)(xX -]{7,20}$/",$value))
{

$errors[] = "$value is not a valid phone no.";

}
}
}
}
//End if not empty
Foreach($_POST as $field => $value)
{
$
$filed strip_tags(trim($value));
}
if(@
is_array($errors))
{
$message_2 "";
foreach(
$errors as $value)
{
$message_2 .= $value."please try again<br/>";
}
Include(
"login_form.inc");
exit();
}    
//End if errors aare found


/*Check to see if username already exists*/
include("dogs.inc");
$cxn mysqli_connect($host,$user,$password,$database)
or die (
"couldnt connect to database");
$sql "SELECT  loginName FROM Member
WHERE LoginName = '
$loginName'";
$result mysqli_query($cxn,$sql)
or die(
"Query died: loginName.");
$num mysqli_num_rows($result);
if (
$num 0)
{
$message_2 "$loginName already used. Select anouther user Nanme.";
include(
"login_form.inc);
exit();
}//end if username exists

else  //add new member
{
[b]
$sql="INSERT INTO Member (loginName,CreateDate,password,lastname,firstname,street,city,state,ZIP,Email,phone,fax)VALUES
('$loginName',NOW(),md5('$password'),'$lastName','$firstName','$street','$city','$state','$ZIP','$email','$phone','$fax')";[/b]

mysqli_query(
$cxn,$sql);
$_SESSION['auth']="yes";
$_SESSION['logname'] = $loginName;
/*send email to new Custome*/
$emess= "You have succesfullymregistered";
$emess .= "user name and passwords are.";
$emess .="\n\n\t$loginName\n\t";
$emess .="$password\n\n";
$emess .= "we appreciate your interest. \n\n";
$emess .= "If you have any questions or problems,";
$emess .= "email me";
$mailsend = mail("$email","$subj","$emess");
header("
locationSecretPage.php");
}
break;
default:
include ("
login_form.inc");
}
?>

Pages: [1]