Can't get next/previous to work...

Codes here !

Moderators: macek, egami, gesf

SomethingRandom
New php-forum User
New php-forum User
Posts: 3
Joined: Tue Sep 11, 2012 2:48 pm

Can't get next/previous to work...

Postby SomethingRandom » Mon Sep 24, 2012 9:30 am

I'm not sure if this is the correct forum to post under, so I'm very sorry if it is the wrong forum. My question deals with my next/previous buttons. I can get my update/delete buttons to work, but I'm so ready to tear out my hair when dealing with the next/previous buttons. Any help would be spectacular! Here's my code. Also, I'm pretty new to PHP so if this is bad coding, please let me know and point me in the right direction so I can fix my mistakes. Thanks!!!

Code: Select all


session_start();

include "connectionfile.php";

if (isset($_POST['fname']) &&
isset($_POST['lname']) &&
isset($_POST['email']) &&
isset($_POST['login']) &&
isset($_POST['password']) &&
isset($_POST['super']) &&
isset($_POST['foldername']))
{
$id = get_post('id');
$fname = get_post('fname');
$lname = get_post('lname');
$email = get_post('email');
$login = get_post('login');
$password = hash('sha256', get_post('password'));
$super = get_post('super');
$foldername = get_post('foldername');

if ($_POST['submit']==0){

$query = mysql_query("SELECT * FROM `Logins` WHERE ID < '".$id."'  ORDER BY ID DESC LIMIT 1;");
while($row = mysql_fetch_array($query)){
   $id = $row['ID'];
   $fname = $row['fname'];
   $lname = $row['lname'];
   $email = $row['email'];
   $login = $row['login'];
   $password = $row['password'];
   $super = $row['super'];
   $foldername = $row['foldername'];

}
}else if ($_POST['submit']==1){
$query = "UPDATE Logins SET fname = '$fname', lname='$lname', email='$email".'@carouselclinical.com'."', login='$login', password='$password', super='$super', foldername='$foldername'";
$query .= "WHERE ID = '$id';";
if (!mysql_query($query, $connect))
echo "INSERT failed: $query<br />" .
mysql_error() . "<br /><br />";

}else if($_POST['submit']==2){

$delete_query = "DELETE FROM Logins WHERE ID = '".$id."';";
mysql_query($delete_query);
$rc = mysql_affected_rows();
echo "Rows Affected " . $rc;

}


if ($_POST['submit']==3){

$query = mysql_query("SELECT * FROM `Logins` WHERE ID= '". $id ."' ORDER BY ID ASC LIMIT 1;");
while($row = mysql_fetch_array($query)){
   $id = $row['ID'];
   $fname = $row['fname'];
   $lname = $row['lname'];
   $email = $row['email'];
   $login = $row['login'];
   $password = $row['password'];
   $super = $row['super'];
   $foldername = $row['foldername'];

}

}
}

mysql_close($connect);

function get_post($var)
{
return mysql_real_escape_string($_POST[$var]);
}
?>

<form action="" method="post"><pre>
id <input type="text" readonly="readonly" name="id" value="<?php echo "$id"; ?>" />
First Name <input type="text" name="fname" value="<?php echo "$fname"; ?>" />
Last Name <input type="text" name="lname" value="<?php echo "$lname"; ?>" />
Email <input type="text" name="email" value="<?php echo "$email"; ?>" /> There's no need to put @carouselclinical.com.
Login <input type="text" name="login" value="<?php echo "$login"; ?>"/>
Password <input type="text" name="password" value="<?php echo "$password"; ?>"/>
Super? <input type="text" name="super" value="<?php echo "$super"; ?>" />
foldername <input type="text" name="foldername" value="<?php echo "$foldername"; ?>" />
<button name="submit" value="0">Previous</button>
<button name="submit" value="1">UPDATE</button>
<button name="submit" value="2">Delete</button>
<button name="submit" value="3">Next</button>
</pre>
<a href="super.php">Home</a> <br />
<a href="logout.php">Log out</a>
</form>

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest