nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, If you don't specify the storage engine type, the default is MyISAM. There are different storage engine types.
Here is the detailed description of the storage engines. http://dev.mysql.com/tech-resources/articles/storage-engine/part_1.html

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

Do you know if I am using the function "$test = mysql_fetch_array" how would I access a variable in that funciton (test["people"]that would give me the value stored in the table as 4.jpg? )

Yep. When you fetch a record from mysql table using mysql_fetch_array, the record will be returned as an array and will be stored in whatever variable you use. $test = mysql_fetch_array($result) will make $test store the array returned by $result. So, you can access that particular array element by specifying the column name,like, $test.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Say for example, I upload 5 images(1,2,3,4,5 .jpg) to the database. So, there will be 5 entries in the table with the peopleid, imagename, etc.
So, If I want to delete an image, say, 4.jpg, I can do it this way.

$image_to_delete = "4.jpg";
$peopleid = my_user_id ;
$path_of_the_image = "people/".$peopleid."/".$image_to_delete;
if(file_exists($path_of_the_image)){
 unlink($path_of_the_image);
} else {
echo "File doesn't exist! ";
}

A simple example.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Ok! In simple terms, You have this query. $query = "SELECT * FROM table $limit"; Just add another line, echo $query after it. It will print something on the screen. Copy it and paste it in phpmyadmin or mysql console. If your query is correct, you will get an output. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

No. Print the query.Execute it.

$query = "select * from tutorials $limit";
echo $query;
nav33n 472 Purple hazed! Team Colleague Featured Poster

Print out the query and test it in phpmyadmin/mysql. Check if the query returns any value.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Search for pagination. You can make use of 'limit' to display only 8 records at a time.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Using css.. :) You can post this question in css to get better replies..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in C:\xampp\htdocs\cycle\logout.php on line 34

That means you are trying to destroy a session that doesn't exist.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Maybe this isn't working. Print some statements inside this loop and execute this script (without logging in). if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT'])) ) {

nav33n 472 Purple hazed! Team Colleague Featured Poster

I'm using Mozilla Firefox. After I logged it, I checked the cookies, there will only 'YourVisitID' under localhost. Then when I press log out button, It will redirect me back to the i.dex.php. Then I tried to copy & paste the direct link to the admin's page., it still works.

Can you post your script of admin's page ? When you run the logout script, sessions should get destroyed. Check if there are still values in the session variable :S

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you validating existence of session in admin's page ? Try ths simple example.

<?php //page1.php
session_start();
$_SESSION['name']="test";
echo "<a href='page2.php'>Click here</a>";
?>

This is page2.php

<?php
session_start();
if(!empty($_SESSION['name'])){
 echo $_SESSION['name'];
} else {
 echo "Invalid session";
}
?>

Well, if you try to access page2.php directly, you will get Invalid session. Are you doing a check like this one in admin's page ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

huh! How do you know it creates another session ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

just echo it. die is an alias of exit and once exit/die is encountered, the execution of the script stops there itself. You can print the error in this fashion !

<?php
if(isset($_POST['submit'])){
  if(empty($_POST['name'])){
    $error="Name field is empty !";
  } else {
  //process the information 
 }
}
?>
<html>
<body>
<form method="post" action="test.php">
<input type="text" name="name"><?php echo $error; ?><br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

So, If the textbox is empty, then $error will have the value, Name field is empty.. If it isn't empty, $error will be null. If its empty, the script wont do anything but show the error message next to the textbox.

nav33n 472 Purple hazed! Team Colleague Featured Poster

if the user changes any values in the checkbox array, I need the db updated with all changes.

You mean, from checked to unchecked and vice versa ? As ShawnCplus has already mentioned, only those checkboxes which are 'set' will be passed on to the next page. Well, if you want to delete certain value when an checkbox is unchecked, then (what I do is), delete all the checkboxes for that particular user, then insert only checked checkboxes. So, it will indirectly delete the unselected checkboxes.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I actually wasn't even aware PHP could use that format for while loops

Yeah.. I wasn't aware too.. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

ah! then thats not a problem. Just get the image name from the table and then concat it with $path="PEOPLE/".$peopleid."/".$imagename !

nav33n 472 Purple hazed! Team Colleague Featured Poster

When you upload the file, you get the path. For, eg,
folder/test/image.jpg. Upload that to the table. You can keep the image name for your reference though.

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you had stored the path, it would have been easy to unlink that file. Just get the path from the table and unlink that 'path'.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Display the link only if the user is admin. Don't display the link for normal users.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Check if its entering if ($row) condition.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Open httpd.conf file in apache/conf and add the line (which I have posted above) in it.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Basically, SHA1, md5, password, encrypt, etc are the encrypting functions. If you encrypt a password field, your application will be more secure. That's all.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you running on a local system or on a server ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Try this.

<table width="1000" height="95" border="1">

<tr>

<td bgcolor="#0000FF">&nbsp;</td>

</tr>

</table>

<?php


include("connect.php");

//this is your validation in the form,put it here....

if (empty($_POST['name']))

{

$errors[] = 'Please enter a name';

}

if (empty($_POST['email']))

{

$errors[] = 'Please enter a valid e-mail address';

}

else if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$",

$_POST['email']))

{

$errors[] = 'Please enter a valid e-mail address';

}

if (empty($_POST['contact']))

{

$errors[] = 'Please enter a valid contact with numeric value';

}

else if (!is_numeric($_POST['contact']))

{

$errors[] = 'Please enter a valid contact with a numeric value';

}

if (empty($_POST['person_attend']))

{

$errors[] = 'Please enter some word for person attend';

}

 

 

else if (strlen ($_POST['person_attend']) > 255)

{

$errors[] = 'person attend';

}


if (empty($_POST['comment']))

{

$errors[] = 'Please enter some comment';

}

else if (strlen ($_POST['comment']) > 255)

{
$errors[] = 'comment ';

}
$name = $_POST['name'];
$email = $_POST['email'];

$contact = $_POST['contact'];
$person_attend = $_POST['person_attend'];

$comment = $_POST['comment'];

if($name="" && $email="" && $contact="" && $person_attend="" && $comment="" ) {
	if(isset($errors))
	{
		foreach($errors as $val)
		{
			echo "Error: $val <br>";
		}
	}
} else {

$name = $_POST['name'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$person_attend = $_POST['person_attend'];
$comment = $_POST['comment'];

$query = "INSERT INTO rsvp (id, name, email, contact, person_attend, comment)
VALUES ('', '$name', '$email', '$contact', '$person_attend', '$comment')";

$results = mysql_query($query) or die 
("Could not execute query : $query." . mysql_error());
echo "Thanks for join us.";
mysql_close();
}
?>


<a href="Index.php">View list attend</a>

One suggestion. Look at how loops, conditions, { } works. You have { } all over …

nav33n 472 Purple hazed! Team Colleague Featured Poster

Sorting non-alphabetical/non-numerical records is not possible AFAIK. But you can have one more field of type int in the table, eg, type. You can enter the order of title, then sort by type !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Instead of passing the strings (your username is.. your password is..) in $message, pass the link. So the user gets the link from where he can update his password.

nav33n 472 Purple hazed! Team Colleague Featured Poster

No. My question is, are you storing the path in the table when the user uploads an image ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

It would be in the mail you send to the users.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Tellme what it prints if you execute only this part of your query.

SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingStateCode, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID

Then, to the above query, add your condition, WHERE a.intLodgeNumber=$id. Then check the result.

P.S. I m off to work. Be back in an hr.

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

huh! maybe, a.intLodgeNumber=$id condition is wrong ? I am not sure.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, I dont have one. But it should be something like this.

$secure_id=md5($email).md5($password).md5("string"); // get $email, $password from the table for that username
$messages.="<a href='pass_update.php?sec=$secure_id&username=$username'>Update your password here! </a>"; 
...
?>

In pass_update.php,

$sec=$_GET['sec'];
//for that username, fetch his email and password from the table
$table_values=md5($email).md5($password).md5("string");
if($table_values == $sec ) { // valid link 
//show the fields to update the password
} else {
//  invalid link the user clicked on an expired link. 
echo "The link isn't valid anymore! ";
exit;
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Is this above query returning the required results ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Instead of sending him his username and password, why not send him a link pass_update.php followed by a string of encrypted key. For example,
pass_update.php?secure=hash(email).hash(prev_password_field)
When the user clicks on the link, check if hash of email and hash of previous_password is valid. If yes, then let him change his password. Once he changes his password, this link becomes inactive. You can add more hashes to the link to make it more secure.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Maybe your query is wrong ? Did you execute it in phpmyadmin/mysql ? Did you get the output which you desired ? I don't know what your query does. Umm.. Execute it first and change it ! limit 50 will show only 50 records! You are grouping the records by name. Maybe thats why you are getting only 1 record ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Nice! Modern art ? eh ? :P

nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay.. I ll make it simple for you.. Here is an example of what you are doing.

<?php
mysql_connect("localhost",'root');
mysql_select_db("test");
$q="select * from table1";
$res=mysql_query($q); //result set of the query
while($row=mysql_fetch_array($res)){ //loop and get all the records for the above query
	echo "first loop".$row[0]."<br />"; 
} //by the end of this query, the internal pointer will be pointing towards the last record. 
while($row=mysql_fetch_array($res)){ //loop for the same resultset.
	echo "second loop".$row[1]."<br />";
} //prints nothing since the pointer is already pointing at the last record in the previous loop.
?>

To make that work, you need to execute your query again. Like this.

<?php
mysql_connect("localhost",'root');
mysql_select_db("test");
$q="select * from table1";
$res=mysql_query($q);
while($row=mysql_fetch_array($res)){
	echo "first loop".$row[0]."<br />";
}
$q="select * from table1";
$res=mysql_query($q);
while($row=mysql_fetch_array($res)){
	echo "second loop".$row[1]."<br />";
}
?>

Notice the difference. Well, Try this code.

<?php
$id = $_GET['id'];

$query = mysql_query("SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingStateCode, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50")or die(mysql_error());
while ($row = @mysql_fetch_array($query)) {
$variable1=$row["strLodgeName"];
$variable2=$row["intLodgeNumber"];
$variable3=$row["strDistrictName"];
$variable4=$row["strLodgeWEB"];
$variable5=$row["strLodgeCounty"];
$variable6=$row["dtChartered"];
$variable7=$row["strLodgeMailingAddress"];
$variable8=$row["strLodgeMailingAddress2"];
$variable9=$row["strLodgeMailingCity"];
$variable10=$row["strLodgeMailingStateCode"];
$variable11=$row["strLodgeMailingPostCode"];
$variable12=$row["strLodgeEmail"];
$variable13=$row["strLodgePhone"];
$variable14=$row["strLodgeFax"];
$variable15=$row["strDrivingDirectons"];
$variable16=$row["dtMeetingTime"];
$variable17=$row["dtMealTime"];
$variable18=$row["strFloorSchool"];
$variable19=$row["strLodgeNews"];
$variable20=$row["strOfficerTitle"];
$variable21=$row["strFirstName"];
$variable22=$row["strLastName"];
$variable23=$row["BusinessPhone"];
$variable24=$row["PersEmail"];

//layout for  Lodge Information results

echo ("<tr>");
echo "<center>\n";
echo "<p>GRAND LODGE OF LOUISIANA - LODGE LOCATOR RESULTS\n</p>";
echo "Lodge Name:$variable1</p>";
echo "<p><b>Lodge Number:</b> $variable2</p>";
echo "<p><b>District Name:</b> $variable3</p>";
echo "<a href=\"$variable4\">Click Here To Go …
nav33n 472 Purple hazed! Team Colleague Featured Poster

As far as I can see, both are coming from the same query.

SELECT a.strLodgeName, a.intLodgeNumber, a.strDistrictName, a.strLodgeWEB, a.strLodgeCounty, a.dtChartered, a.strLodgeMailingAddress, a.strLodgeMailingAddress2, a.strLodgeMailingCity, a.strLodgeMailingStateCode, a.strLodgeMailingPostCode, a.strLodgeEmail, a.strLodgePhone, a.strLodgeFax, a.strDrivingDirectons, a.dtMeetingTime, a.dtMealTime, a.strFloorSchool, a.strLodgeNews, b.strOfficerTitle, b.strFirstName, b.strLastName, b.BusinessPhone, b.PersEmail FROM tblLodges a LEFT JOIN tblOfficers b ON a.lngLodgeID = b.lngLodgeID WHERE a.intLodgeNumber=$id GROUP BY a.strLodgeName LIMIT 50

. Check if your query is returning the rows you want to use. As far as I know, when you are using the resultset in the first while, the pointer will be pointing to the last record. So, I dont think in the second while loop, the recordset will remain the same.
Well, execute the query again before the second while. ie., $query=mysql_query("your query");
and use the while loop.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you storing the path of the uploaded image in the table? If yes, you can do as I have mentioned above. If you aren't storing the path in the table, then you need to opendir , readdir and then unlink the files. See example 2 of readdir. Instead of echo-ing, you can unlink.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Or, you have to make php parse the files with html extensions. Add AddType application/x-httpd-php .html to your httpd.conf file of apache. It will parse html files as php.

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

oh..hmm ! If the user has uploaded the images, there will be an entry for every uploaded images in the database. (ie., the path of the 5 images.) Get all the records for that particular user and then delete them. for example, if the user with userid 3 has uploaded 5 images. There will be 5 entries in the table image_upload(which contains the path of the images).

$q="select * from image_upload where userid='5'";
$result=mysql_query($q); //the query returns 5 records 
while($row=mysql_fetch_array($result)){
  $imagepath=$row['path']; //$imagepath will have the path of the uploaded image. 
unlink($imagepath);//delete the file
//then delete the directory. I hope you are saving the images into the directory which is named after userid.
}
rmdir(5); //remove the directory with userid 5. 
?>
Sulley's Boo commented: *grabs nav33n by the ear* i (((DONNOT))) wear glasses anymore! +4
nav33n 472 Purple hazed! Team Colleague Featured Poster

What is the problem ? When the user uploads an image, I m sure you will be saving the path of the image. When the user clicks on delete, get the id of that image and unlink the file. What exactly is your problem ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Someone got bored and 'drilled' holes (small, medium and big) on a piece of paper using a pen ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Great! Congrats..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. I don't see any missing ; in the above scripts. The only thing thats wrong is,

"Welcome $msg;"

It should have been <?php echo "Welcome $msg"; ?> . But that has nothing to do with process.php. Check for missing ; in process.php . (cuz I dont see any!)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you sure it doesn't work ? Its works on my computer though. What is the error you are getting this time ?
Edit: Btw, in voting page, you need to request msg.
ie., $msg=$_GET;

nav33n 472 Purple hazed! Team Colleague Featured Poster

Do you want alternate colors for columns ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

instead, initialise $nr0 to 0 outside while loop. initialise $nr0 at the end of while loop.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi ! missing semicolon in these lines.

$msg=$user << here
         header ("Location:vote_page.php?$msg=$msg");
		break;
	case "Jim":
         $msg=$user  << here

Cheers,
Naveen

Edit: Btw, this header ("Location:vote_page.php?$msg=$msg") should be header ("Location:vote_page.php?msg=$msg") , if you want to use $msg value in vote_page.php !

nav33n 472 Purple hazed! Team Colleague Featured Poster

hmm! okay !

scorpionz commented: Naveen is a Great Guy ... With Great Knowledge +2