Previous Thread
Next Thread
Print Thread
Rate Thread
#278391 08/22/2004 8:30 AM
Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
ok, I dont know where to even start because I dont know the name of what im supposed to be looking for.

What I want to do is take this page Here and make it so I can edit all the yellow spaces from online.

They are tournament brackets and everytime I have a tourney I have to download the code, edit it, and then upload it again. And I have to do it after every game so its kept current.

I dont know what the correct wording is that Im tring to do in php.

If I can make a page that shows the brackets, where I can type in the names of the winners and loosers where the yellow names are and then "submit" it. It will then add the information to the tournament page without me having to dl it and re-upload it with changes.

Im not askig for someone to do it (if you are wanting to do it then fine with me) But I am asking, if I want to learn how to do this, what is the process called?

Its basically like the "contact us" mod where you fill in the info and it send you an email. But in this case I want it to send the info to a page thast displayed...

I hope you are not as lost as I am by now........

Sponsored Links
Joined: Aug 2004
Posts: 8
Newbie
Newbie
Offline
Joined: Aug 2004
Posts: 8
Depends on how complex you want it.

If you want to be able to save your data, without
entering it all everytime you'll need to save your data
in some kind of database. Do you have mysql support by your
web provider ?

Without a database, just php you can do this :

Create 2 files, "setup.htm", and "game.php"
Code
 <br /> <br />In setup.htm : <br /> <br /><html> <br /><body> <br /><form action="game.php" method="POST"> <br />Team 1 : <input type="text" name="team1" /> <br />Team 2 : <input type="text" name="team2" /> <br />G1W    : <input type="text" name="g1w" /> <br />... etc <br />... <br /><input type="submit" /> <br /></form> <br /></body> <br /></html> <br />


In game.php (i.e your current web page)
find all your "Team 1", "G1W" etc and change
them to :

Code
 <br />......  <?php echo $_POST["team1"]; ?>.<br /> <br /> <br />......  <?php echo $_POST["team2"]; ?>.<br /> <br /> <br />......  <?php echo $_POST["g1w"]; ?>.<br /> <br /> <br /> 


Then run load setup.htm.

It will load game.php, and fill in the variables (team1,team2) etc.

You'll have to save that web page back to the server, as say
"gamestatus.htm". This will be the file the users access.

If you want to eliminate the saving step, you'll need to use some kind
of database to save your entry form values, then have a php page read
those values.

In that case, the first file, (setup.htm), would write the values to a database.

Then you'll have to load "game.php" with the variables filled in.

This is interesting. I'll work on the second type (saving to a db), just for fun. Let me know if you have access to a database on your web site.

Mike

Last edited by mstram; 08/22/2004 5:53 PM.
Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
I am my own host so I have, and can access, sql. Thisnis aomething that I have been working on for a while.

Someone cameout with a phpnuke teournament script that used to be free. They had this setup exactly as im tring to do built in to the script. Now you have to purchase it for 99.00. Not that is not worth 99.00 but to go from free to 99.00 is quite a jump.

I can gladly give the entire source code for the tourney brackets on my forums to anyone that wants to use it. Its not something that you have to pay for. it was an open source script that I modified, alot, to get it the way I wanted it. Thats the best I could come up with.

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
ok.
I added the sample code to the actual page. This would be the page that you edit online and submit with changes that no one will see . eventually it will be passworded.

Check the code to see if its correct and will work when submitted to the database. I know there is no code yet that actually makes the submit work because it should go to a database anyway. but its a start..

I also didnt add the boxes to the second round section yet

New page linkey....

Joined: Aug 2004
Posts: 8
Newbie
Newbie
Offline
Joined: Aug 2004
Posts: 8
[]DrChaos said:
Check the code to see if its correct and will work when submitted to the database. I know there is no code yet that actually makes the submit work because it should go to a database anyway. but its a start..
[/]

The code appears to be ok. I'll play with it.

Do you have php on your system now? If you do, you can test your form, by putting the <?php echo $_POST["team1"]; ?> tags into to your original doc, and saving it with a .php extension.

You'll need to install mysql, and I suggest installing phpMyadmin as a tool to admin the database.

Mike

Sponsored Links
Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
I have all that in my cpanel

Ill get to play with it some tonight. Its getting it to save the info in sql that gonna be the hard one.

Joined: Aug 2004
Posts: 8
Newbie
Newbie
Offline
Joined: Aug 2004
Posts: 8
[]DrChaos said:
I have all that in my cpanel
[/]

Have all what? .. MSQL ? ... PhpMYadmin?

[]
Its getting it to save the info in sql that gonna be the hard one. [/]

Anything is hard when you don't know how to do it

There are tons of php-mysql tutorials out there.

Here's one

http://www.createafreewebsite.net/phpmysql/phpmysql_introduction.html

It can all be pretty overwhelming when you dive in to setp a web site. Web servers, php/perl/cgi, database, html are all big topics on their own, tieing up all the pieces is tall order when you are just starting out.

You seem to have a good start on the HTML (web page design)

Read up on some basic tutorials about SQL, if you don't know anything aobut it. MYsql is pretty easy to use "out of the box", the only thing you need to check is your security settings, which is highlited and explained pretty well in the docs.

PhpMyadmin or any of the other gui database front ends are all fairly intutitive to use for the basics, once you have a fundamental idea of how a relational database works.

The code to add new data or update the database is actually quite simple and only a few lines of code.

Mike

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
I have a server that I rent from a company online. with that server, I have a re-sellers contract that I can sell hosting. I also have cpanel and sql, phpmyadmin, the works.

I use whm to manage all the sites. On my personal domain, I use cpanel and have access to phpmyadmin and unlimited sql databases. So to answer your questions, they are installed already.

SQL seems not to be too hard if you just know the basic stuff. Although I have no idea about it, I am learning.

I modified the page I posted to show the form boxes that will be edited as the tournament goes on. This is the page im using as the log in page for tourney admins.

I will be using the same page but with the code to pull the information from the sql database to display any changes that have been made as the tourney goes on.....

I cant seem to find the answer to...
Does each "post box" have to have its own table in sql?
and what is the code to call the info from sql to the page that is viewed by everyone...

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
ok, im officially stuck...

I cant seem to understand how to get the page that I am adding information to, to save in the sql. and that is causing me not to be able to view the finished page.

anyone want to send me in a direction, any direction

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
what you need to do is create a html form page that takes your input and then when you submit it sends that data into an sql command that INSERTS the data into a mysql database. Its really a very simple thing...

do the following create a form called widget.php

<?
if ($action != 'do' ){
echo "<HTML><HEAD><TITLE>My Tournament</TITLE></HEAD>";
echo "<BODY>";
echo "<H1>My Tournament Input</H1>";
echo "<FORM METHOD=POST ACTION="widget.php">";
echo "Edit place H1: <INPUT NAME="H1" SIZE="4" VALUE="100">";
echo "<INPUT TYPE="RESET" VALUE="Clear">";
echo "<INPUT TYPE="SUBMIT" VALUE= "SUBMIT H1">";
echo "</FORM>";
echo "</BODY>";
echo "</HTML>";
}
else{


$host = "localhost";
$username = "username";
$password = "password";
$database = "name of database";
$table = "name of table";

$server = mysql_connect($host, $username, $password) or die(mysql_error());

$connection = mysql_select_db($database, $server);

mysql_db_query("$database", "INSERT INTO $database.$table (H1)
VALUES ('$GET(H1)')");

mysql_close($server);
}
?>

that will insert the data now you could link to the main.inc.php of threads and use their functionality in mysql.inc.php to do the functions so you wouldn't have to write them in this format it depends on what you want to do..

Sponsored Links
Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
Don't forget to add slashes to the variables you get from the form to prevent sql injections.

Joined: Aug 2004
Posts: 8
Newbie
Newbie
Offline
Joined: Aug 2004
Posts: 8
[]scroungr said:

<?
if ($action != 'do' ){
[/]

I'm curious to know how that actually works, or does anything at all in this script.

I ran it and it doesn't work on my system (php 4.3.4)

Now this does work :


$action = $_POST['action'];
if ($action != 'do' ){
...
else {
echo "<FORM METHOD=POST ACTION="widget1.php">";
echo "Edit place H1: <INPUT NAME="H1" SIZE="4" VALUE="100">";
echo "<INPUT TYPE="hidden" name="action" value="do" />";
....

==================
Also :

mysql_db_query("$database", "INSERT INTO $database.$table (H1)
VALUES ('$GET(H1)')");

I don't understand what or how the $GET(H1) is supposed to work either.


Mike

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
cause I wrote something simple with globals on and your probably running your server with globals off.. yes it needs to be tweaked I only made an example.. if ya want the whole code I would need the html table he is using....

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
I cant even keep up with the pros on this... I pm'ed scroungr the complete file and where I was. allthough I am not very far It might shed some some light on what Im tring to accomplish.

I know that if this gets goin and some other functions can get added, alot, and I mean alot, of people will want and use it.

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
Do to recent "happenings" I had to format and re-install.
Dont ask, yes I lost everything. Im using this thread as a guideline again but it just kinda faded out with no replies.

I added what scroungr said, Dont understand what Anno wants me to do, mstram totally threw a brick at me

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
>Dont understand what Anno wants me to do

Read about sql injections
http://www.securiteam.com/securityreviews/5DP0N1P76E.html

Joined: Nov 2002
Posts: 554
Code Monkey
Code Monkey
Offline
Joined: Nov 2002
Posts: 554
OMG Dr. I am so sorry to hear that Let me know if I can help in any way

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
All mstram is saying that if the php I posted doesn't work it means your server is running globals off so use

if ($_POST[action] != 'do' ){

instead of

if ($action != 'do' ){

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
ima trin it

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
worked :

this is what I get. I think this is right?

Now, I have to make this input accept names. Like a persons name or clan name. It looks like its set as as numbers.

Now, If on the page that everyone sees (the brackets page) I have to set one slot to be called H1 and then set that to pull from the sql so it will always show what I put in this page correct?

if so, at this point do I just repeat the code over and over naming each one to H1, H2, H3, H4, and so on?

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
wait for me to finish I am almost done if I get a second top finsih coding the brackets.. I had to create an on the fly bracket system

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
whew. I know, I think I said alot in that post

But im still tring to lean it. sql is very powerful and php is just another world.

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
then yes thats what ya wanna do.. actually I wrote a whole database structure for adding players, teams, sports, tournaments, etc.... but I had to develope the on the fly brackets.. should be be able to work on it this week

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
WOOT!!!!!


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)