Variable in URL in from Action - php

<body>
<?php
$domain = $_POST['domainname'];
?>
<form action="http://" "<?php print $domain; ?>:2083/login" method="POST">
<input type="hidden" name="login_theme" value="cpanel">
<table width="200" class="login" cellpadding="0" cellspacing="0">
<tr>
<td align="left"><b>Login</b></td>
<td> </td>
</tr>
<tr>
<td>Domain</td>
<td>
<input autocomplete="off" type="text" name="domainname" size="16">
</td>
</tr>
<tr>
<td>Username</td>
<td>
<input autocomplete="off" type="text" name="user" size="16">
</td>
</tr>
<tr class="row2">
<td>Password</td>
<td>
<input type="password" name="pass" size="16">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Login" class="input-button">
</td>
</tr>
</table>
</form>
</body>
I have this code on a basic php file. My goal is to have a centralised hub for cpanel users to login into.
They will input their domain name, username and password into the form, the form will take them to http://theirdomain.com/cpanel and log them in by passing the credentials through.
Only problem I am having is outputting the domain variable in the form's action to make it go there. Just getting 'about:blank'
EDIT: I have moved the redirect script over to a second file, and it seems to be redirecting to the domain fine now.
However, now the credentials won't pass through.

<form action="http://<?php echo $domain; ?>:2083/login" method="POST">
<!--form content-->
</form>

Ended up with this (probably not the cleanest, but it works)
index.php
<?php
$domain = $_POST['domainname'];
?>
<form action="cplogin.php" method="post">
Domain: <input type="text" name="domainname" size="50" /><br />
Username: <input type="text" name="user" size="50" /><br />
Password: <input type="password" name="pass" size="20" autocomplete="off" /><br />
<input type="submit" class="btn btn-red" name="login" value="Login" />
</form>
and cplogin.php
<?php
$domain = $_POST['domainname'];
if(!$_POST['login']) {
exit;
}
$user = $_POST['user'];
$pass = $_POST['pass'];
$port = "2083";
$port == "2083" || $port == "2083" ? $pre = "https://" : $pre = "https://";
?>
<body onLoad="setTimeout('document.forms[0].submit();',10)">
<form action="<?php echo "".$pre."".$domain.":".$port."/login/"; ?>" method="post">
<input type="hidden" name="user" value="<?php echo $user; ?>">
<input type="hidden" name="pass" value="<?php echo $pass; ?>">
</form>

Related

creating a login page but button click doesn't show any data or error messages

When i click on the submit button it doesn't show any error and does not respond with any message.after a click it only reload itself and doesn't show any data. please reply me with the error.
I found I missed the tag. It was a silly mistake.
<?php
$server="localhost";
$username="root";
$password="admin007#";
$dbname="demo";
$con=new mysqli($server,$username,$password,$dbname);
if(!$con)
{
die('error connecting to the database');
}
if(isset($_POST['login'])){
$a=mysqli_real_escape_string($con, $_POST['user']);
$b=mysqli_real_escape_string($con, $_POST['pass']);
$sql="SELECT * FROM login WHERE username='$a' AND password='$b'";
$result=mysqli_query($con, $sql);
$check=mysqli_num_rows($result);
if($check>0){
echo "you are logged in";
}
else
{
echo "Error";
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<tr>
<td>Username:</td>
<td><input type="text" name="user" value=""/></td>
</tr>
<br /><br />
<tr>
Password:
<td><input type="password" name="pass" value=""/></td>
</tr>
<br />
<tr align="center">
<td colspan="2"><input type="submit" name="login" value="Log In"/></td>
</tr>
</body>
</html>
There is a <form> Tag missing
<body>
<form action="#" method="post">
<tr>
<td>Username:</td>
<td>
<input type="text" name="user" value="" />
</td>
</tr>
<br />
<br />
<tr>
Password:
<td>
<input type="password" name="pass" value="" />
</td>
</tr>
<br />
<tr align="center">
<td colspan="2">
<input type="submit" name="login" value="Log In" />
</td>
</tr>
</form>
</body>
The <form method="post"> around the input fields is missing. Besides that, the <table> is also missing :)
Make the magic happen with something like:
<body>
<form method="post">
<table>
<tr>
<td>Username:</td>
<td><input type="text" name="user" value=""/></td>
</tr>
<tr>
Password:
<td><input type="password" name="pass" value=""/></td>
</tr>
<tr align="center"><td colspan="2"><input type="submit" name="login" value="Log In"/></td></tr>
</table>
</form>
</body>
PS: No <br> Tags between <tr> Tags - thats semantic nonsense (use CSS instead) ... and modern day HTML developers will go full rage when you use <table> tags for layout purposes :)

accessing the user profile by clicking a link

Good day! I am building an online learning site, wherein every user has their own account and they can view their profile through the link of "my profile" whenever they click it. I have tried connecting it to log in but it goes directly to the profile page. This is my codes for instructor_profile.php, how can I connect the link(my profile) from the instructor's menu to profile page? Thank you.
<?php
mysql_connect("localhost", "root", "root");
mysql_select_db("db_elearning");
$idNumber = $_REQUEST['idNumber'];
$get = mysql_query("SELECT * FROM tbl_instructor WHERE idNumber = '$idNumber'");
$get2 = mysql_fetch_assoc($get);
$username = $get2['username'];
$password = $get2['password'];
$lastName = $get2['lastName'];
$firstName = $get2['firstName'];
$middleName = $get2['middleName'];
$location = $get2['location'];
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body,td,th {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 18px;
}
</style>
</head>
<body>
<p> </p>
<p> </p>
<p><br />
</p>
<form id="form1" name="form1" method="post" action="">
<p align="center"><strong>Instructor's profile</strong> </p>
<table border="0" width="30%" align="center">
<tr><td width="40%">
<label for="username">Username</label> </td> <td>
<input type="text" name="username" id="username" value="<?php echo $username;?>" />
</td> </tr>
<tr><td width="40%">
<label for="password">Password</label> </td> <td>
<input type="text" name="password" id="password" value="<?php echo $password;?>" />
</td> </tr>
<tr><td width="40%">
<label for="lastName">Last name</label> </td> <td>
<input type="text" name="lastName" id="lastName" value="<?php echo $lastName;?>" />
</td> </tr>
<tr><td width="40%">
<label for="firstName">First name</label> </td> <td>
<input type="text" name="firstName" id="firstName" value="<?php echo $firstName;?>" />
</td> </tr>
<tr><td width="40%">
<label for="middleName">Middle name</label> </td> <td>
<input type="text" name="middleName" id="middleName" value="<?php echo $middleName;?>" />
</td> </tr>
</td> </tr>
<tr><td width="40%">
<label for="location">Location</label> </td> <td>
<input type="text" name="location" id="location" value="<?php echo $location;?>" />
</td> </tr>
</table>
</form>
</body>
</html>
This is the instructor's log in, it just goes directly to the user's profile
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if($username && $password){
mysql_connect("localhost", "root", "root") or die("Connection to server failed!");
mysql_select_db("db_elearning");
$query = mysql_query("SELECT * FROM tbl_instructor WHERE username ='$username'");
$numrows = mysql_num_rows($query);
if($numrows != 0){
while($row = mysql_fetch_assoc($query)){
$idNumber = $row['idNumber'];
$dbname = $row['username'];
$dbpassword = $row['password'];
}
if($username==$dbname){
if($password==$dbpassword){
header("location:instructor_frame.html");
if ($numrows ==1){
header("location:instructor_profile.php?idNumber=$idNumber");
}else{
echo "Your password is incorrect!";
}
}else{
echo "Your name is incorrect!";
}
}else{
echo "This name is not registered!";
}
}else{
echo "You have to type a name and password!";
}
}
?>
i will tell you how i would do it:
first of all, i will create a config.php and functions.php, which i will include in index.php,
here is my config.php:
<?php
$link = mysqli_connect($db_host,$db_user,$db_pass,$db_name);
// Check connection
if (!$link){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
here is my functions.php:
<?php
function getInstructorsProfileById($id){
global $link;
$sql = "SELECT * FROM 'tbl_instructor' WHERE 'idNumber' = '$idNumber'";
$res = mysqli_query($link,$sql);
$row=mysqli_fetch_assoc($res);
return $row;
}
?>
(Warning up in the code area i cant use the type of quotes i need, so be aware that on the table/column name, inside $sql, you have to use that type of quotes, on my keyboard is on the left of the key 1 it also has ~ if shift is pressed)
and my index.php page is:
<?php
include 'config.php';//necesarily the first
include 'function.php'; // so it would have the global $link variable to call
if(isset($_GET['idNumber'])){
$someVar = getInstructorsProfileById($_GET['idNumber']);
extract($someVar);
?>
<form id="form1" name="form1" method="post" action="">
<p align="center"><strong>Instructor's profile</strong> </p>
<table border="0" width="30%" align="center">
<tr><td width="40%">
<label for="username">Username</label> </td> <td>
<input type="text" name="username" id="username" value="<?php echo $username;?>" />
</td> </tr>
<tr><td width="40%">
<label for="password">Password</label> </td> <td>
<input type="text" name="password" id="password" value="<?php echo $password;?>" />
</td> </tr>
<tr><td width="40%">
<label for="lastName">Last name</label> </td> <td>
<input type="text" name="lastName" id="lastName" value="<?php echo $lastName;?>" />
</td> </tr>
<tr><td width="40%">
<label for="firstName">First name</label> </td> <td>
<input type="text" name="firstName" id="firstName" value="<?php echo $firstName;?>" />
</td> </tr>
<tr><td width="40%">
<label for="middleName">Middle name</label> </td> <td>
<input type="text" name="middleName" id="middleName" value="<?php echo $middleName;?>" />
</td> </tr>
</td> </tr>
<tr><td width="40%">
<label for="location">Location</label> </td> <td>
<input type="text" name="location" id="location" value="<?php echo $location;?>" />
</td> </tr>
</table>
</form>
<?php }else{
echo "some error if there is no number assigned";
}
?>
and the link to this page would be:
<?php $idNumber =7; // the number you know you need, example 7 ?>
My Profile
but this is not the best way, to have a better approach try and search the web for the words session_start(), $_SESSION in php syntax
Hope this helps

PHP form to send email from Website

This is my html form requesting feedback.
What would the corresponding PHP form be to place on my webserver to send the email? I am new at website design and have only learnt CSS+ HTML.
<table width="518" border="0">
<tr>
<td width="165"><form name="form1" method="post" action="">
<label for="nameco">Name/Company</label>
:
</form></td>
<td width="343"><input name="nameco" type="text" id="nameco" size="70"></td>
</tr>
<tr>
<td><form name="form2" method="post" action="">
<label for="area">Area you are located :</label>
</form></td>
<td><input name="area" type="text" id="area" size="70"></td>
</tr>
<tr>
<td><form name="form3" method="post" action="">
Products interested in :
</form></td>
<td><table width="198">
<tr>
<td width="190"><label>
<input type="radio" name="Product" value="awnings" id="Product_0">
Awnings</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="Product" value="carport" id="Product_1">
Carport/Shadeport</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="Product" value="patio" id="Product_2">
Patio</label></td>
</tr>
<tr>
<td><label>
<input type="radio" name="Product" value="other" id="Product_5">
Other
<input type="text" name="other1" id="other1">
</label></td>
</tr>
</table></td>
</tr>
<tr>
<td><form name="form4" method="post" action="">
<label for="contactno">Contact Number :</label>
</form></td>
<td><input name="contactno" type="text" id="contactno" size="70"></td>
</tr>
<tr>
<td><form name="form5" method="post" action="">
<label for="email">Email Address :</label>
</form></td>
<td><input name="email" type="text" id="email" size="70"></td>
</tr>
<tr>
<td><form name="form7" method="post" action="">
<label for="Comments">Additional Comments :</label>
</form></td>
<td><input name="Comments" type="text" id="Comments" size="70"></td>
</tr>
<tr>
<td><form name="form8" method="post" action="">
<input type="submit" name="Submit" id="Submit" value="Submit">
</form></td>
<td><form name="form9" method="post" action="">
<input type="submit" name="reset" id="reset" value="Reset Form">
</form></td>
</tr>
</table>
This is from dreamweaver. And how do i let the form know to send via this PHP file?
If I can give you advise, don't use so many forms, just use one and set action in send.php.
send.php can look like this:
<?php
$to = "$_POST['email']";
$subject = "$_POST['subject']";
$message = "$_POST['message']";
$from = "your#email.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

Error when trying to fill in registration fields

I'm trying to create a login and registration system with PHP for a school assignment, but it's currently not really working...
The problem is it generates an error saying the fields are empty, even when you filled the fields in with data, so it shouldn't give this error.
The code:
<html>
<head>
<title>Music Database</title>
<link rel="stylesheet" href="layout.css" type="text/css" />
<?php
// Verbinden met de database //
include('connect.php');
// Registreer data verkrijgen en in variabelen zetten //
if(isset($_POST['r_submit'])){
$r_username = $_POST['r_username'];
$r_password = $_POST['r_password'];
$confirm_r_password = $_POST['confirm_r_password'];
$r_name = $_POST['r_name'];
$r_surname = $_POST['r_surname'];
$r_birth = $_POST['r_dateofbirth'];
$r_mail = $_POST['r_mail'];
}
?>
</head>
<body>
<div id="login">
<form name="login" action="login.php" method="post">
<p>Login: <input class="input" type="text" name="username" value="Username" />
<input id="password" type="password" name="password" value="Password" /></p>
<div><a class="link" href="register.php">Register here!</a></div>
<p align="center"><input class="submit" type="submit" name="login_submit" value="Submit" /></p>
</form>
</div>
<div id="header">
<a class="link" href="index.php">Music Database</a>
</div>
<div id="search">
<form name="search" action="search.php" method="post">
<p>Search for: <input class="input" type="text" name="search" value="<?php if(isset($_POST['search'])) print $_POST['search']; ?>" />
<input class="submit" type="submit" name="search_submit" value="Submit" /></p>
<p>Artist: <input type="checkbox" name="artistsearch" checked />
Album: <input type="checkbox" name="albumsearch" />
Song: <input type="checkbox" name="songsearch" />
Genre: <input type="checkbox" name="genresearch" /></p>
</form>
</div>
<div id="wrapper"><br /></div>
<div id="content">
<h1>Register down here please:</h1>
<table id="wrap_table">
<tr>
<td>
<div id="reg_content">
<div id="reg_form">
<form name="register_login" action="register.php" method="post">
<fieldset>
<legend>Login Data: </legend>
<table class="r_table">
<tr>
<td>Username<sup>*</sup>: </td>
<td><input class="input" type="text" name="r_username" value="<?php if(isset($r_username)){ print $_POST['r_username']; } ?>"/></td>
<?php
if(isset($_POST['r_submit'])){
if(!isset($r_username)){
echo "<td>Error: No Username has been entered!</td>";
}
}
?>
</tr>
<tr>
<td>Password<sup>*</sup>: </td>
<td><input class="input" type="password" name="r_password" value="<?php if(isset($r_password)){ print $_POST['r_password']; } ?>"/></td>
<?php
if(isset($_POST['r_submit'])){
if(!isset($r_password)){
echo "<td>Error: No Password has been entered!</td>";
}
}
?>
</tr>
<tr>
<td>Confirm Password<sup>*</sup>: </td>
<td><input class="input" type="password" name="confirm_r_password" value="<?php if(isset($confirm_r_password)){ print $_POST['confirm_r_password']; } ?>"/></td>
<?php
if(isset($confirm_password)){
if($confirm_r_password != $r_password){
echo "<td>Error: The passwords don't match!</td>";
}
}
?>
</tr>
</table>
</fieldset>
</form>
</div>
</td>
<td>
<div id="reg_form">
<form name="register_personal" action="register.php" method="post">
<fieldset>
<legend>Personal Data: </legend>
<table class="r_table_personal">
<tr>
<td>Name: </td>
<td><input class="input" type="text" name="r_name" value=""/></td>
</tr>
<tr>
<td>Surname: </td>
<td><input class="input" type="text" name="r_surname" value=""/></td>
</tr>
<tr>
<td>Date of Birth: </td>
<td><input class="input" type="text" name="r_dateofbirth" value=""/></td>
</tr>
<tr>
<td>E-mail<sup>*</sup>: </td>
<td><input class="input" type="text" name="r_mail" value="<?php if(isset($r_mail)){ print $_POST['r_mail']; } ?>"/></td>
<?php
if(isset($_POST['r_submit'])){
if(!isset($r_mail)){
echo "<td>Error: No E-mail has been entered!</td>";
}
}
?>
</tr>
</table>
</fieldset>
</form>
</div>
</div>
</td>
</tr>
<tr>
<td>Fields with an asterisk<sup>*</sup> are required for registry!
<div id="reg_content">
<form name="submit_registry" action="register.php" method="post">
<input class="submit" type="submit" name="r_submit" value="Submit!" />
</form>
</div>
</td>
</tr>
</table>
</div>
<div id="footerbreak"><br /></div>
<div id="footer"> © Jorik ter Molen & Camiel Collet, 2011.</div>
</body>
do you have your <form action="" method="post"> in there?
you can also debug your $_POST global to see whats happening (if data is hitting your script)
var_dump($_POST);
So you include the first "form" page in the second php file after the code right?
First of all in the PHP file you should add all the
if(isset($_POST['submit'])){
segments into one:
if(isset($_POST['submit'])){
$r_username = $_POST['r_username'];
$r_password = $_POST['r_password'];
$confirm_r_password = $_POST['confirm_r_password'];
$r_name = $_POST['r_name'];
$r_surname = $_POST['r_surname'];
$r_birth = $_POST['r_dateofbirth'];
$r_mail = $_POST['r_mail'];
}
Your problem is most probably in $_POST['submit'] since you have two checks, one for $_POST['submit'] and another for $_POST['r_submit']
Unless you send it both ways i suggest you change the PHP file to check for 'r_submit'
Update:
Try putting the form inside the register.php page so it looks like this:
<?php
if(isset($_POST['r_submit'])){
$r_username = $_POST['r_username'];
$r_password = $_POST['r_password'];
$confirm_r_password = $_POST['confirm_r_password'];
}
?>
<form action="register.php" method="post">
<td>Username<sup>*</sup>: </td>
<td><input class="input" type="text" name="r_username" value="<?php if(isset($r_username)){ print $_POST['r_username']; } ?>"/></td>
<?php
if(isset($_POST['r_submit'])){
if(!isset($r_username)){
echo "<td>Error: No Username has been entered!</td>";
}
}
?>
</tr>
<tr>
<td>Password<sup>*</sup>: </td>
<td><input class="input" type="password" name="r_password" value="<?php if(isset($r_password)){ print $_POST['r_password']; } ?>"/></td>
<?php
if(isset($_POST['r_submit'])){
if(!isset($r_password)){
echo "<td>Error: No Password has been entered!</td>";
}
}
?>
</tr>
<tr>
<td>Confirm Password<sup>*</sup>: </td>
<td><input class="input" type="password" name="confirm_r_password" value="<?php if(isset($confirm_r_password)){ print $_POST['confirm_r_password']; } ?>"/></td>
<?php
if(isset($confirm_password)){
if($confirm_r_password != $r_password){
echo "<td>Error: The passwords don't match!</td>";
}
}
?>
</tr>
<input name="r_submit" type="submit" value="Submit" />
</form>
Solution:
<html>
<head>
<title>Music Database</title>
<link rel="stylesheet" href="layout.css" type="text/css" />
<?php
// Verbinden met de database //
include('connect.php');
// Registreer data verkrijgen en in variabelen zetten //
if(isset($_POST['r_submit'])){
$r_username = $_POST['r_username'];
$r_password = $_POST['r_password'];
$confirm_r_password = $_POST['confirm_r_password'];
$r_name = $_POST['r_name'];
$r_surname = $_POST['r_surname'];
$r_birth = $_POST['r_dateofbirth'];
$r_mail = $_POST['r_mail'];
}
?>
</head>
<body>
<div id="login">
<form name="login" action="login.php" method="post">
<p>Login: <input class="input" type="text" name="username" value="Username" />
<input id="password" type="password" name="password" value="Password" /></p>
<div><a class="link" href="register.php">Register here!</a></div>
<p align="center"><input class="submit" type="submit" name="login_submit" value="Submit" /></p>
</form>
</div>
<div id="header">
<a class="link" href="index.php">Music Database</a>
</div>
<div id="search">
<form name="search" action="search.php" method="post">
<p>Search for: <input class="input" type="text" name="search" value="<?php if(isset($_POST['search'])) print $_POST['search']; ?>" />
<input class="submit" type="submit" name="search_submit" value="Submit" /></p>
<p>Artist: <input type="checkbox" name="artistsearch" checked />
Album: <input type="checkbox" name="albumsearch" />
Song: <input type="checkbox" name="songsearch" />
Genre: <input type="checkbox" name="genresearch" /></p>
</form>
</div>
<div id="wrapper"><br /></div>
<div id="content">
<h1>Register down here please:</h1>
<table id="wrap_table">
<tr>
<td>
<div id="reg_content">
<div id="reg_form">
<form name="register_login" action="register.php" method="post">
<fieldset>
<legend>Login Data: </legend>
<table class="r_table">
<tr>
<td>Username<sup>*</sup>: </td>
<td><input class="input" type="text" name="r_username" value="<?php if(isset($r_username)){ print $_POST['r_username']; } ?>"/></td>
<?php
if(isset($_POST['r_submit'])){
if(!isset($r_username)){
echo "<td>Error: No Username has been entered!</td>";
}
}
?>
</tr>
<tr>
<td>Password<sup>*</sup>: </td>
<td><input class="input" type="password" name="r_password" value="<?php if(isset($r_password)){ print $_POST['r_password']; } ?>"/></td>
<?php
if(isset($_POST['r_submit'])){
if(!isset($r_password)){
echo "<td>Error: No Password has been entered!</td>";
}
}
?>
</tr>
<tr>
<td>Confirm Password<sup>*</sup>: </td>
<td><input class="input" type="password" name="confirm_r_password" value="<?php if(isset($confirm_r_password)){ print $_POST['confirm_r_password']; } ?>"/></td>
<?php
if(isset($confirm_password)){
if($confirm_r_password != $r_password){
echo "<td>Error: The passwords don't match!</td>";
}
}
?>
</tr>
</table>
</fieldset>
</div>
</td>
<td>
<div id="reg_form">
<fieldset>
<legend>Personal Data: </legend>
<table class="r_table_personal">
<tr>
<td>Name: </td>
<td><input class="input" type="text" name="r_name" value=""/></td>
</tr>
<tr>
<td>Surname: </td>
<td><input class="input" type="text" name="r_surname" value=""/></td>
</tr>
<tr>
<td>Date of Birth: </td>
<td><input class="input" type="text" name="r_dateofbirth" value=""/></td>
</tr>
<tr>
<td>E-mail<sup>*</sup>: </td>
<td><input class="input" type="text" name="r_mail" value="<?php if(isset($r_mail)){ print $_POST['r_mail']; } ?>"/></td>
<?php
if(isset($_POST['r_submit'])){
if(!isset($r_mail)){
echo "<td>Error: No E-mail has been entered!</td>";
}
}
?>
</tr>
</table>
</fieldset>
</div>
</div>
</td>
</tr>
<tr>
<td>Fields with an asterisk<sup>*</sup> are required for registry!
<div id="reg_content">
<input class="submit" type="submit" name="r_submit" value="Submit!" />
</div>
</form>
</td>
</tr>
</table>
</div>
<div id="footerbreak"><br /></div>
<div id="footer"> © Jorik ter Molen & Camiel Collet, 2011.</div>
</body>
Around line 82 where you have the php check for the matching passwords, replace it with:
<?php
if(isset($_POST['r_submit'])){
if($confirm_r_password != $r_password)
{
echo "<td>Error: The passwords don't match!</td>";
}
}
?>
Although this is just a basic check and nothing secure since the user can leave both passwords empty and they still match.

Can't put PHP form in a table

I've created a form which works fine, but when I put it in a table it always thinks the form is incomplete - is there a way I can put it in a table (so it looks nice!) without this problem?
-----My HTML------
<h2 class="green">Interested in making life easier?</h2>
<form method="post" action="sendemail.php">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
Name:
<input type="text" name="visitor" size="25" />
<br />
Address:<input type="text" name="visitoradd" size="25" />
<br />
City:<input type="text" name="visitorcity" size="15" />
<br />
Postcode:<input type="text" name="visitorpost" size="15" />
<br />
Email:<input type="text" name="visitormail" size="25" />
<br />
Telephone Number:<input type="text" name="visitortel" size="25" />
<br />
Bookkeeping/Payroll:<select name="bp" size="1">
<option value=" Bookkeeping">Bookkeeping </option>
<option value=" Payroll ">Payroll</option>
</select>
<br />
Number of transactions: <input type="text" name="transcations" size="15" />
<br />
Number of employees:<input type="text" name="employees" size="15" />
<br />
Payroll weekly/monthly:<select name="pmw" size="1">
<option value=" Weekly">Weekly</option>
<option value=" Monthly">Monthly</option>
</select>
<br />
<br />
<INPUT TYPE="image" SRC="images/btnSubmit.png" ALT="Submit Form">
<br />
</form>
-----My PHP-----
<?php
$visitor = $_POST['visitor'];
$visitoradd = $_POST['visitoradd'];
$visitorcity= $_POST['visitorcity'];
$visitorpost= $_POST['visitorpost'];
$visitormail = $_POST['visitormail'];
$visitortel = $_POST['visitortel'];
$bp = $_POST['bp'];
$transcations = $_POST['transcations'];
$employees = $_POST['employees'];
$pmw = $_POST['pmw'];
if(!$visitormail == "" && (!strstr($visitormail,"#") || !strstr($visitormail,".")))
{
echo "<h2>Please enter valid e-mail.</h2>\n";
$badinput = "<h2>Click the back button to retry.</h2>\n";
echo $badinput;
die ("Thank you.");
}
if(empty($visitor) || empty($visitormail) || empty($visitorcity) || empty($visitorpost) || empty($visitoradd) || empty($visitortel) || empty($bp) || empty($transcations) || empty($employees) || empty($pmw) || empty($pmw))
{
echo "<h2>Please fill in all fields, click the back button to retry</h2>\n";
die ("Thank you.");
}
$message = "
Name: $visitor\n
Address: $visitoradd\n
City: $visitorcity\n
Post Code: $visitorpost\n
Email: $visitormail\n
Phone Number: $visitortel\n
Bookkeeping/Payroll: $bp\n
Number of Transactions: $transcations\n
Number Of Employees: $employees\n
Payroll Weekly/Monthly: $pmw\n"
;
$subject = "Payment Details";
mail("contact#email.com",$subject,$message,$visitormail);
?>
<p align="center">
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />
<br />
Click here to Finish
</p>
<h2 class="green">Interested in making life easier?</h2>
<form method="post" action="sendemail.php">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<table>
<tr>
<td><label for="visitor">Name:</label></td>
<td><input type="text" name="visitor" size="25" /></td>
</tr>
<tr>
<td><label for="visitoradd">Address:</label></td>
<td><input type="text" name="visitoradd" size="25" /></td>
</tr>
<tr>
<td><label for="visitorcity">City:</label></td>
<td><input type="text" name="visitorcity" size="15" /></td>
</tr>
<tr>
<td><label for="visitorpost">Postcode:</label></td>
<td><input type="text" name="visitorpost" size="15" /></td>
</tr>
<tr>
<td><label for="visitormail">E-mail:</label></td>
<td><input type="text" name="visitormail" size="25" /></td>
</tr>
<tr>
<td><label for="visitortel">Telephone Number:</label></td>
<td><input type="text" name="visitortel" size="25" /></td>
</tr>
<tr>
<td><label for="bp">Bookkeeping/Payroll:</label></td>
<td>
<select name="bp" size="1">
<option value=" Bookkeeping">Bookkeeping </option>
<option value=" Payroll ">Payroll</option>
</select>
</td>
</tr>
<tr>
<td><label for="transcations">Number of transactions:</label></td>
<td><input type="text" name="transcations" size="15" /></td>
</tr>
<tr>
<td><label for="employees">Number of employees:</label></td>
<td><input type="text" name="employees" size="15" /></td>
</tr>
<tr>
<td><label for="pmw">Payroll weekly/monthly:</label></td>
<td>
<select name="pmw" size="1">
<option value=" Weekly">Weekly</option>
<option value=" Monthly">Monthly</option>
</select>
</td>
</tr>
</table>
<br />
<INPUT TYPE="image" SRC="images/btnSubmit.png" ALT="Submit Form">
<br />
</form>
Place the form tags outside of the table like so:
<form>
<TABLE>
<TR>
<TD>Name</TD>
<TD><input type="text" name="visitor" size="25" /></TD>
</TR>
<TR>
<TD>Address</TD>
<TD><input type="text" name="address" size="25" /></TD>
</TR>
</TABLE>
</form>
If you are needing to specify width, height, etc.. then use CSS.
Here is a great tutorial on it: http://www.w3schools.com/css/

Categories