...

View Full Version : help making a form



njfail
11-14-2010, 12:04 AM
Can someone help me make a form that updates a list of names/#s?

When I try to experiment with the form functions it loads another page that the list is located on; I want the form and the list to be on the same page.

For example:
user: njfail
#: 111
Submit (click)

Then below that it updates the list of users with:
njfail #111

(the # is not related in anyway to the problem here).

mlseim
11-14-2010, 12:58 AM
Not enough information.

Do you have some sort of database?

Do you have an actual form you can show us, along with some PHP scripting?

DrDOS
11-14-2010, 01:11 AM
This is his previous post on this issue:

http://www.codingforums.com/showthread.php?t=209026

Personally I think it would be a lot simpler to keep the separate form and just code the page so that it returns to the index.php page.

PS: Just the other day I wrote up a nice little login page for two entries. I might be a good start for your project. You just need to make a blank file, players.php, with the right permissions to see if it works for you. A lot needs to be added, such as checking the entries and reading the file to the index page in the format you need, but that's all very straightforward code.

PPS: Added some code to make it function without errors. Needs more checking and code to write to the page..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<script type="text/javascript">
//Alerts to errors.
window.onerror=function(msg, url, linenumber){var logerror='Error message: ' + msg + '. Url: ' + url + 'Line Number: ' + linenumber;alert(logerror);return false}
</script>
<script type="text/javascript">
function showLogin()
{
var m = document.getElementById("mylogin");
m.style.display="block";
var c = document.getElementById("cover");
c.style.display="block";
c.style.width="100%";
}
function hideLogin()
{
var m = document.getElementById("mylogin");
m.style.display="none";
var c = document.getElementById("cover");
c.style.display="none";
c.style.width="0";
}
</script>
<title></title>
<style type="text/css">
html{background:#333}
body{width:900px;margin:auto;margin-top:40px;color: White}
body a {color: #aff}
#mylogin
{
background: #369;
padding:20px;
width:300px;
height:auto;
position:absolute;
z-index:100;
left:50%;
margin-left: -150px;
top:50%;
margin-top: -160px;
border: 2px solid #fff;
-moz-border-radius: 16px;
-webkit-border-radius: 16px;
-khtml-border-radius: 16px;
border-radius: 24px;
}
#dologin
{
border: 2px solid #fff;
-moz-border-radius: 12px;
-webkit-border-radius: 12px;
-khtml-border-radius: 12px;
border-radius: 12px;
}
#cover
{
background: #000;
height:100%;
position:absolute;
top: 0;
left: 0;
z-index: 90;
}
</style>
<?php
if (isset($_POST['submit']))
{
$player = $_POST['player'];
$number = $_POST['number'];
//echo $player.$number;
if (($player !="Your Name" || $number !="Your Number")&&( $player !="" || $number !=""))
{
$message = fopen("players.php","a");
fwrite($message,"<br><span class=\"player\">".$player.": #".$number."</span><br>\n");
fclose($message);
}
}
?>
</head>
<body><a href="#" onclick="showLogin();">Login</a><br>
<h4>Heading here</h4>
Some text here.
<div id="cover"></div>
<div id="mylogin" style="display:none">
<fieldset id="dologin">
<legend>Log in to the site.</legend>
<form name="logmein" id="logmein" action="" method="post">
<input type="text" name="player" value="Your Name"><br>
<input type="text" name="number" value="Your Number">
<input type="submit" name="submit" value="Enter Data">
<input type="button" value="Exit" href="#" onclick="hideLogin();">
</form></fieldset></div>
<?php include('players.php') ?>
<script type="text/javascript"></script>
</body>
</html>

DrDOS
11-14-2010, 07:20 PM
Will this do for you? I updated my post above with the new code. It completely functions in the way you wanted, but it can be made much more sophisticated. Here is a link to the fopen function in PHP that might be useful.

http://www.php.net/manual/en/function.fopen.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum