Jump to content

Merge Two Files


Dysan

Recommended Posts

Hi,

 

Can the following HTML (Form) and PHP code be merged into one file?

 

HTML

<!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>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<form name="form1" id="form1" method="post" action="login.php">
  <label>ID:</label>
  <input name="id" type="text" id="id" />
  <br />
  <br />
  <input name="save" type="submit" id="save" value="Save" />
</form>
</body>
</html>

 

 

PHP

[code=php:0]<?php
session_start();
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
  die(mysql_error());
}

mysql_select_db("db", $con);

$id = mysql_real_escape_string($_POST['id']);

$data = mysql_query("SELECT * FROM users WHERE id='$id'");
$row = mysql_fetch_array($data);

  if(!mysql_num_rows($data)==0)
  {
    $_SESSION['token'] = 1;
    $_SESSION['user'] = $row['name'];
    $_SESSION['account'] = $row['account'];
    header("location: userpage.php"); 
    exit(); 
  }
  else
  {
    echo "Login Unsuccessful!";
  }


mysql_close($con);
?>

[/code]

Link to comment
https://forums.phpfreaks.com/topic/86707-merge-two-files/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.