Jump to content

Index.htm going to login page and sending back to index page


ghosh

Recommended Posts

Hello,

This is what I intend to do.

 

1: A visitors visits a.html page. decides to login and post comment. goes to login page and logs in then I want to send him back to a.html page how do I do that? Here is my login page and login.php page.

 

2: Same as above but I want to send them back after some time... while I make them view the error, why they have not been able to login.

 

<?php
session_start();
include "connect.php";
?>
<?php
if(isset($_POST['submit']))
{
  	$emailid=$_POST['email'];  //Email id and password should be checked against the database.
  	$password=$_POST['password'];
$password=md5($password);
  	$getuser="SELECT * from a_users where email='$emailid' and passkey='$password' and validated='1'";
  	$getuser2=mysql_query($getuser) or die("Could not query for user");
  	$getuser3=mysql_fetch_array($getuser2);
  		if((strlen($getuser3[email])<1)||$getuser3[validated]==0)
  			{
    		header(Location:"http://www.myplanet.co.in/home/members/invalid-username-password.php";
		}
	else if($getuser3[isbanned]=="yes")
  			{
    		print "Your account has been banned. <br><br><br> <center>For more information contact webmaster: helpdesk@myplanet.co.in<br><br><br><br>copyright myplanet</center>";
  			}
	else
  			{
		$_SESSION['email']=$emailid;   //Once the email ID and password has been varified.
			if(isset($_SESSION['email']))
				{
					 $emailid=$_SESSION['email']; //retriving user name against the given email ID.
  					 $getusername="SELECT * from a_users where email='$emailid'";
  					 $getusername2=mysql_query($getusername) or die("Could not get user name");
  					 $getusername3=mysql_fetch_array($getusername2);
                                         $username=$getusername3['username'];
				 }				
			else
				{
				echo "ALERT: USER NAME DOES NOT EXIST";	 
    				}

		$path = '/folder/';
		$hostname = 'myplanet.co.in';
		setcookie('myplanet', $username, $emailid, $path, $hostname);		//setting cookie for storing email ID and Password.

		}
}			
  ?>

 

Hope you dont mind me putting the domain name as it is!

 

Thanks,

Link to comment
Share on other sites

ok, you mean to say i send him to a simple age where he learns the status and send him back but how do I know from which web address he came from. In a website there could be many page from where he can visit the login.php page!!

 

Alternatively, is there any ways I can make him wait in a page for some time before sending him to another?

 

Thanks for helping me.

Link to comment
Share on other sites

You will not be able to sustain a login within a html page unless your server is setup to handle *.html files as php.

 

Ok, I will keep all my pages as php but isn't it php files are bigger in size than html and loads late?

Link to comment
Share on other sites

here is the forum which I am using. which is not working. The page is continuously getting refreshed and multiple similar comments are getting added. Redirection is also not working.

<?php
//create the form to submit comments
//you can add more fields, but make sure you add them to the db table and the page, submitcomment.php
        echo "<a name=\"post\"><div id=\"submitcomment\" class=\"submitcomment\">
<form name=\"submitcomment\" method=\"post\" action=\"submitcomment.php\" onSubmit=\" return form_Validator(this)\">
<table width=\"100%\">
                <tr>
                                <th colspan=\"2\"><h3 class=\"formtitle\">Leave your comment:</h3></th>
                </tr>
                <tr>

                                <th scope=\"row\"><p class=\"req\">Name:</p></th>
                                <td><input class=\"form\" tabindex=\"1\" id=\"name\" name=\"name\" /></td>
                </tr>
                <tr>
                                <th scope=\"row\"><p class=\"opt\">Email:</p></th>
                                <td><input class=\"form\" tabindex=\"2\" id=\"email\" name=\"email\" /></td>
                </tr>
                <tr>

                                <th scope=\"row\"><p class=\"opt\">URL:</p></th>
                                <td><input class=\"form\" tabindex=\"3\" id=\"url\" name=\"url\" /></td>
                </tr>
                <tr valign=\"top\">
                                <th scope=\"row\"><p class=\"req\">Comments:</p><br /></th>
                                <td><textarea class=\"formtext\" tabindex=\"4\" id=\"message\" name=\"message\" rows=\"10\" cols=\"50\"></textarea></td>
                </tr>

                <tr>    
                                <td> </td>
                                <td><input type=\"submit\" name=\"post\" class=\"submit\" value=\"Submit Comment\" /><br />
                                <p>Note:  Emails will not be visible or used in any way, and are not required.  Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted. </p>

<p>No HTML code is allowed.  Line breaks will be converted automatically.  URLs will be auto-linked.  Please use BBCode to format your text.</p>

</td>
                </tr>
</table>
<input type=\"hidden\" name=\"tuturl\" value=\"$tuturl\" /> 
<input type=\"hidden\" name=\"tutid2\" value=\"$tutid2\" />
</form>


</div>
";
}
?>

This is the submit comment.php

<?php
//Please set the following variables for your mysql database:
$db_hostname = "localhost";  //usually "localhost be default"
$db_username = "";  //your user name
$db_pass = "";  //the password for your user
$db_name = "";  //the name of the database


/*MYSQL DATABASE CONNECTION/ TRACKING FUNCTIONS
--------------------------------------*/
// connect to database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);


$tuturl = $_POST["tuturl"];
$tutid2 = $_POST["tutid2"];
$name = $_POST["name"];
$url = $_POST["url"];
$email = $_POST["email"];
$message = $_POST["message"];

$sendcomment = mysql_query("INSERT INTO comments SET tutorialid='$tutid2', name='$name', url='$url', email='$email', comment='$message', date=now()");
if($sendcomment){
//header("Location: $tuturl");
echo "<h1>Submission Successful</h1>";
echo "Your comment has been submitted.  You will now be redirected back to the last page you visited.  Thanks!";
echo "<meta http-equiv='refresh' content='2;URL=$tuturl'>";
} else {
echo "There was an error with the submission. ";
}

?>

 

 

I would appreciate if some one can figure out the mistake!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.