Jump to content

Placing PHP into HTML webpages and linking correctly

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Mikeemc

Mikeemc

    Newbie

  • Members
  • Pip
  • 2 posts
I have been looking around for about a week and reading into PHP, I want to create a register and log in type website and realise i need to use php to do this, I already have the html but inserting the PHP into this is where I am stuck, I have checked FAQ's etc but Im thinking now its actually that simple its not being mentioned to me(a newbie).

this is the stage I am at (purely for function) I have managed to get the range of PHP files from another thread (index.php, insert.php, login.php, logout.php, register.php) and made a database using wampserver (was told to in a previous tutorial)

> I have index.html page, with register and login entry form,

<hmtl> <(changed on purpose for this post)
<body>

<h1>Login</h1>
<form action='login.php' method='POST'>
    Username: <input type='text' name='username'/><br />
    Password: <input type='password' name='password'/><br />
    <input type='submit' value='Log In'>
</form>

<h1>Register</h1>
<form action='register.php' method='POST'>
    Username: <input type="text" name="username"/><br />
    Password: <input type="password" name="password"/><br />
    Repeat password: <input type="password" name="repassword"/><br />
    <input type="submit" value="Register!"/>
</form>
</body>
</html> 

> when i type in asif i want to register, it then goes to http/:etc/etc/register.php

how ever this page will not have a layout, as if it needs its own CSS, and also has the extra characters on the page, very much confusing.

http://imageshack.us.../808/rpage.jpg/
(ImageShack® - Online Photo and Video Hosting)

if that img link doesnt work I attached the jpeg anyway,

> I want something much like this codecall website, I had to register, which then sent me to a register page, which was in the normal site layout, then once registered, a thankyou again in normal site layout but I did notice at top it had the www.codecall.net/register.php <<< my register.php is a mess, and I am not sure how to turn it into a HTML with a stylesheet, basically linking them together,

if there is another thread that you have noticed that answers this then i would like to get directed it, as I have only been on this site inparticular looking a few hours, some kind of basic, zip even that shows the different pages and how they link together.

thanks alot for any help,

Mike

Attached Files


Edited by Orjan, 10 January 2012 - 11:46 AM.
Added html tags


#2
SoN9ne

SoN9ne

    Programmer

  • Members
  • PipPipPipPip
  • 129 posts
Please post using proper tags so it is easier for others to read your post.

Login:
<h1>Login</h1>

<form action="/login.php" method="post">

	Username: <input type="text" name="username" /><br />

	Password: <input type="password" name="password" /><br />

	<input type="submit" value="Log In" />

</form>

Register:
<h1>Register</h1>

<form action="/register.php" method="post">

	Username: <input type="text" name="username" /><br />

	Password: <input type="password" name="password" /><br />

	Repeat password: <input type="password" name="repassword" /><br />

	<input type="submit" value="Register!" />

</form>

For sake of simplicity and showing you how your data is sent you can use this for you php files.
You will need to handle the logic in these files obviously.
login.php && register.php
<?php 

if (!empty($_POST)) {

	die('<pre>'.print_r($_POST, true).'</pre>');

}

?>

Once you have the logic in place you can force the user to a new page by using the header function
header('Location: /newpage.php');

"Life would be so much easier if we only had the source code."




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users