PDA

View Full Version : Looking For A Script



Angey
03-06-2006, 01:28 AM
Hello everyone,

I was wondering if anyone knows of a script I can use to make a list of endorsements on a website.

What I am wanting is way for visitors to fill out a form with their name, street address, and profession and then when they click submit it adds their information to a list that is generated and shown to all viewers on the same webpage. It would be a list of people who endorse a local school bond.
It does not have to be php but I didn't know where else to start. I have tried petition scripts and guestbook scripts but these just aren't what I'm looking for.

Thanks for any suggestions

djr33
03-06-2006, 02:53 AM
If you can write the form in html, just point it to a php page to interpret it.
In that php page, get the data from the form (probably use the method of post) and do what you want with it. Then you'll need a database or a way to connect to a file and store it in that.
A database, if you have access to it, would probably work well... just look for any basic tutorial thru google, cut/paste their connection/add to db scripts, and there ya go.

Then, to display the results on a page, you just need to reverse the process... get the data from the database. There are also example tutorials out there that are quite easy to follow.

If you'd rather use a text file or something, that's possible as well... just seems like it might be a bit more work to figure out as I haven't seen any tutorials for doing so. I haven't looked too much, though.

Hope this gets you started...

Angey
03-06-2006, 02:58 AM
Hmmm, sounds a bit confusing but I really know nothing about PHP. I have just figured out by trial and error, in the last two days, how to install a PHP script lol

I do know I can get the form created in HTML. Dreamweaver has some options for that.

Not sure what you mean when talking about this method of post or anything else.

I can create databases in my host server.

I don't know, I half understand what your saying but not enough to actually make it work.

Thank you for pointing me in the right direction though!

djr33
03-06-2006, 04:45 AM
Ok. From what you posted, it was hard to tell if you understood php yet or not.
It's not that hard... I just have been getting into it in the last few weeks, and I can do what you're trying to do... so you'll probably be fine.


Further explanation:

If you can write the form in html, just point it to a php page to interpret it.
In that php page, get the data from the form (probably use the method of post) and do what you want with it.Write the form in html. Put it on a php page or not. doesn't matter. in the initial <form> tag, put:
<form ... method="post" action="INTERPRETINGPAGE.php">
That will make it take the user to that php page and also give the info to the next page, thru 'post variables' (see post above. 'get' is another method, but for longer entries and such post is better-- get puts them at the end of the url-- 'http://.../page.php?GETVARIABLE=something&another=etc')


Then you need to get the post variables into your php script on the next page.
Firstly, organize your page like this:
<?php INSERTADDINGTODATABASESTUFFHERE ?>
<html>...</html>
That way, you can have whatever message you want displayed when the user views the page, and then you can also have your php script at the top. It'll keep it organized.
Ok... so... to get the post variables:
the way that php deals with variables is by adding them to something or other called global values or something... doesn't really matter. in the end, you have to get these values like this:

$input = $_POST['input']
Replace input with your value (*name of the field in the form.)
That way, the 'input' thing in the form is now stored as the php variable $input ($ indicates a variable in php).
now you can do what you want with $input. If it were a number, you could, for example, add one to it. You have lots of options. In this case, you want to add this and other inputted values to a database.

Then you'll need a database or a way to connect to a file and store it in that.
A database, if you have access to it, would probably work well... just look for any basic tutorial thru google, cut/paste their connection/add to db scripts, and there ya go.As I said... google a tutorial.
Or.. here you go: http://www.php-mysql-tutorial.com <used that myself. Easy and fast.

basically... get your database info and set it up. Then the trick will be getting mysqlconnect(*info*) to work... it can get a bit tricky the first time, just getting used to working with it.
now... use that link I gave you. I'll tell you how to connect, then add to the database.
You should probably look over most of it first.
you don't really need to setup a database within the database... it already has one, depending on your hosting setup... mine does, so that part of the tutorial is kinda a waste.
then just use the code (AFTER you've made a table to store stuff in) that adds values to the database. its one of the pages. should be easy enough.

Ok... now... you've (hopefully, if all goes well above) got your info IN the database. but how does that help you? well... just get it out. that same page has a section on it. really quite easy.

Use php to get the values out, according to the tutorial, then, for example, store a value as '$output'.
Then you have to figure out how you want your page with the stuff to be displayed on it to look.
Use a php look to do something like this:

(note: echo is the php command that will output a variable or stuff in quotes to html.)

while(*see the tutorial for a while loop getting stuff from a database*) {
echo "<table width=100>";
echo "<b>";
echo $output;
echo "</b>";
echo "</table>";
}
Its not like that's what you'll really want, but that would create a table for each value and put it in there, as bold text. You can format the html how you want.
Remember, if you have more than one variable, as you surely will (name, email, message, etc etc) you will have more than one variable like $output, that you get from the database and store as what you want. Take that, put them into your loop as well.

I hope this helps you get started.
Really... just play with this stuff.
It should start making sense soon.