1
General PHP Help / Re: Display query in reverse order? help help help help help
« on: May 12, 2012, 09:28:58 AM »
Your a genius!!!!!!!!!!!!!!!!!!!!!!!!!! thnx
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.

function AddField( $assoc, $column, $style )
{
echo ' <td class= "'. $style . '">'. $assoc[$column] . "</td>\n";
}
<?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>";
}
?>
[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]
<?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("location: SecretPage.php");
}
break;
default:
include ("login_form.inc");
}
?>