rjcfan4ever Posted July 25, 2011 Share Posted July 25, 2011 I need a Contact me script, what directly knows the user his username and password. Someone maybe knows such a script? Here is my login page and members page: <?php include "base.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>User Management System (Tom Cameron for NetTuts)</title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="main"> <?php if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { ?> <h1>Member Area</h1> <p>Thanks for logging in! You are <b><?=$_SESSION['Username']?><b> and your email address is <b><?=$_SESSION['EmailAddress']?></b>.</p> test <p> </p> </p> <ul> <li><a href="logout.php">Logout.</a></li> </ul> <?php } elseif(!empty($_POST['username']) && !empty($_POST['password'])) { $username = mysql_real_escape_string($_POST['username']); $password = md5(mysql_real_escape_string($_POST['password'])); $checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'"); if(mysql_num_rows($checklogin) == 1) { $row = mysql_fetch_array($checklogin); $email = $row['EmailAddress']; $_SESSION['Username'] = $username; $_SESSION['EmailAddress'] = $email; $_SESSION['LoggedIn'] = 1; echo "<h1>Success</h1>"; echo "<p>We are now redirecting you to the member area.</p>"; echo "<meta http-equiv='refresh' content='2;url=index2.php' />"; } else { echo "<h1>Error</h1>"; echo "<p>Sorry, your account could not be found. Please <a href=\"index2.php\">click here to try again</a>.</p>"; } } else { ?> <h1>Member Login</h1> <p>Thanks for visiting! Please either login below, or <a href="register.php">click here to register</a>.</p> <form method="post" action="index.php" name="loginform" id="loginform"> <fieldset> <label for="username">Username:</label><input type="text" name="username" id="username" /><br /> <label for="password">Password:</label><input type="password" name="password" id="password" /><br /> <input type="submit" name="login" id="login" value="Login" /> </fieldset> </form> <?php } ?> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/ Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 25, 2011 Share Posted July 25, 2011 are the data stored in MySQL database? Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1246876 Share on other sites More sharing options...
rjcfan4ever Posted July 25, 2011 Author Share Posted July 25, 2011 are the data stored in MySQL database? Ehm.. no I only need a Contact script what directly knows the user his username and email so the user does not need to fill in. Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1246886 Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 25, 2011 Share Posted July 25, 2011 this should work <?php if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { ?> Username:<input type="text" value="<?php echo $_SESSION['Username'];?>" id="username"/><br/> Email: <input type="text" value="<?php echo $_SESSION['EmailAddress'];?>" id="email"/> <!-- the rest of the scripts --> Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1246888 Share on other sites More sharing options...
rjcfan4ever Posted July 25, 2011 Author Share Posted July 25, 2011 Cool really thanx Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1246896 Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 25, 2011 Share Posted July 25, 2011 HAHA. No Prob Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1246898 Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 25, 2011 Share Posted July 25, 2011 please mark topic as sloved. it can be found at the bottom left of the page Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1246900 Share on other sites More sharing options...
rjcfan4ever Posted July 25, 2011 Author Share Posted July 25, 2011 Now I got another problem.. He keeps erroring here is the script, he says syntax error on line 85 <?php if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username'])) { ?> Username:<input type="text" value="<?php echo $_SESSION['Username'];?>" id="username"/><br/> Email: <input type="text" value="<?php echo $_SESSION['EmailAddress'];?>" id="email"/> <?php /* Set e-mail recipient */ $myemail = "you@domain.com"; /* Check all form inputs using check_input function */ $yourname = check_input($_POST['yourname'], "Enter your name"); $subject = check_input($_POST['subject'], "Write a subject"); $email = check_input($_POST['email']); $website = check_input($_POST['website']); $likeit = check_input($_POST['likeit']); $how_find = check_input($_POST['how']); $comments = check_input($_POST['comments'], "Write your comments"); /* If e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("E-mail address not valid"); } /* If URL is not valid set $website to empty */ if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website)) { $website = ''; } /* Let's prepare the message for the e-mail */ $message = "Hello! Your contact form has been submitted by: Name: $yourname E-mail: $email URL: $website Like the website? $likeit How did he/she find it? $how_find Comments: $comments End of message "; /* Send the message using mail() function */ mail($myemail, $subject, $message); /* Redirect visitor to the thank you page */ header('Location: thanks.htm'); exit(); /* Functions we used */ function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1246937 Share on other sites More sharing options...
wildteen88 Posted July 25, 2011 Share Posted July 25, 2011 Where is line 85? Can you point it out to us. Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1246940 Share on other sites More sharing options...
rjcfan4ever Posted July 25, 2011 Author Share Posted July 25, 2011 How? Can't u just put it on dreamweaver or stuff? Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1246958 Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 26, 2011 Share Posted July 26, 2011 line 85 is the last line. Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1247152 Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 26, 2011 Share Posted July 26, 2011 does it error after the you send the form or when you open the page? Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1247155 Share on other sites More sharing options...
ZulfadlyAshBurn Posted July 26, 2011 Share Posted July 26, 2011 you have to edit this part /* Let's prepare the message for the e-mail */ $message = "Hello! Your contact form has been submitted by: Name: $yourname E-mail: $email URL: $website Like the website? $likeit How did he/she find it? $how_find Comments: $comments End of message "; to this /* Let's prepare the message for the e-mail */ $message = "Hello! Your contact form has been submitted by: Name: " . $yourname ." E-mail: " . $email ." URL:" . $website ." Like the website? $likeit How did he/she find it?" . $how_find ." Comments:" . $comments . " End of message "; Quote Link to comment https://forums.phpfreaks.com/topic/242760-i-need-a-contact-script-what-directly-knows-the-user-his-username-and-password/#findComment-1247156 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.