PDA

View Full Version : form contents to Word doc


d a v e
03-22-2010, 05:37 PM
is this possible and how hard would it be for me to do? (wasn't sure whether this is a php thing or not, sory if it's in the wrong place)

"a log in script, generating that form letter that uses tenant name and inserts their name, address, into a word letter" ? i guess a pdf could be a possible alternative too ;)

oh and how hard is it to do a login area anyway? how much more expensive , approximately, would it make it?

for example how many hours would it take you to do??

davidj
03-22-2010, 05:57 PM
Why not do a mail merge from your users table within your database

http://forums.mysql.com/read.php?79,194373,194373

tux
03-22-2010, 09:30 PM
A simple login consists of a login script, a logout script and of course the page you want to protect. You will obviously need a database containing your users info.

Here is a very simple login script with a form for username and password. Edit it to include your database connection and ensure your table and field names are correct. Name it login_script.php.

<?php
require_once("your connection script here"); // or your database connection code here instead
///////////////////////////////////////////
session_start();
/////////////////////////////////////////
$username = $_POST['username'];
$password = $_POST['password'];
$submitted = $_POST['submitted'];
/////////////////////////////////////////

if($username && $password){
///////////////////////////////////////// edit 'users' to the name of your database table
$query = sprintf("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
$result = @mysql_query($query);
$user = @mysql_fetch_array($result);
/////////////////////////////////////////
}
if($user){
$_SESSION['id'] = $user['userID'];
header("location:your_account.php");
exit;
}elseif($submitted){
echo "LOGIN FAILED. Your username and password combination was not correct. Please try again.";
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login</title>

</head>

<body>

<form name="login" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="submitted" value="1" />

Username<input name="username" type="text" id="username" />

Password<input name="password" type="password" id="password" />

<input type="submit" name="login" id="login" value="login" />
</form>

</body>
</html>

Here is a logout script, name it logout_script.php

<?php

session_start();

session_destroy();

header("location:login_script.php");
exit;

?>

and finally a simple account page with a logout button. Name it your_account.php

<?php

session_start();

///////////////////////////////////////////
if(! isset($_SESSION['id'])){
header("location:login_script.php");
exit;
}

echo "Welcome to your account, you are logged in.";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Your Account</title>
</head>

<body>

<form name="logout" method="post" action="logout_script.php">
<input type="submit" name="logout" id="logout" value="logout" />
</form>

</body>
</html>

This is very basic but I hope it helps you get the idea.

Cant help with your other issue but I'm Davidj will put you right.

Regards, Paul

d a v e
03-22-2010, 10:33 PM
thanks guys - just needed some idea to put in my bid ;)

edbr
03-23-2010, 02:29 AM
good luck with your bid. we all know you have helped many posters in the past I think/ hope its clear you have a support group here if you need it ,

davidj
03-23-2010, 08:18 AM
hope its clear you have a support group here if you need it
My names david and im an alcoholic!

edbr
03-23-2010, 10:02 AM
i thought it was you!!