Log in

View Full Version : Is there a code or script that..



Dudey!
29-07-2008, 01:59 PM
Allows users to submit data/information onto your site?

Such as, "Add your own tips" kind of thing? Possible?

Moh
29-07-2008, 02:05 PM
Allows users to submit data/information onto your site?

Such as, "Add your own tips" kind of thing? Possible?
Of course :)

VPSwow
29-07-2008, 02:12 PM
Someone on this forum may make one for you because i dont think it will be that hard to make but what do i know ;).

Dudey!
29-07-2008, 05:56 PM
Someone on this forum may make one for you because i dont think it will be that hard to make but what do i know ;).

Okay, you know anyone that could do it?

-terrior-
29-07-2008, 07:23 PM
do u just want a Form to put on your website where it sends an e-mail to u with what the user put in?

if yes PM me and i could do - but not for free - well i could do for free but not to soon becuase im busy if u offer Paypal / Habbo (depends on what it is) I will put to top priority

Thanx

-terrior-

Dudey!
29-07-2008, 07:42 PM
do u just want a Form to put on your website where it sends an e-mail to u with what the user put in?

if yes PM me and i could do - but not for free - well i could do for free but not to soon becuase im busy if u offer Paypal / Habbo (depends on what it is) I will put to top priority

Thanx

-terrior-

No thanks, i know how to do that.

I want it to the user submits > adds to site.

Tom-743
29-07-2008, 08:02 PM
do u just want a Form to put on your website where it sends an e-mail to u with what the user put in?

if yes PM me and i could do - but not for free - well i could do for free but not to soon becuase im busy if u offer Paypal / Habbo (depends on what it is) I will put to top priority

Thanx

-terrior-
Are you kidding?

Something that takes less than 5 minutes to do and you are charging for it (if you do wan't one of those forms pm me and I will do it for free.)

Calon
29-07-2008, 08:12 PM
The best way to do it, or the way I'd do it would be with php/mysql.

PHP
http://www.php.net/
MySQL
http://www.mysql.com/



<?php
mysql_connect("host", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());

function silence($string)
{
$string = htmlspecialchars( $string, ENT_QUOTES );
if( get_magic_quotes_gpc( ) ) {

$string = stripslashes( $string );

}

$string = mysql_real_escape_string( $string );

return $string;
}


if(!$_POST["Submit"]) {

echo "<form action=\"\" method=\"post\">
<input type=\"text\" name="tipsAuthor" />
<input type=\"text\" name=\"tips\" />
<input type=\"submit\" name=\"Submit\" />
</form>";

}
else {

$clean["author"] = silence($_POST["tipsAuthor"]);
$clean["tip"] = silence($_POST["tips"]);

mysql_query("INSERT INTO tips (author, tip) VALUES('$clean["author"]', '$clean["tip"]' ) ") or die(mysql_error());

}
?>

Think that should work, also..

http://www.cpanel.net/media/tutorials/mysqlwizard.htm (If you don't know how top set-up a database.

Once you've done that, create a table called "tips" in phpMyAdmin.
With the fields:

"author" and "tip" without the quotation marks.

wsg14
29-07-2008, 08:19 PM
First create a database name tips, with whatever username and password you desire. (remember to edit the MySql details in config.php with your username and password). Then in that database, run the following query:


CREATE TABLE `tips` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 25 ) NOT NULL ,
`author` VARCHAR( 35 ) NOT NULL ,
`content` TEXT NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM
Now here's the codes for each page:

index.php

<?php
require_once("config.php");
?>

<a href="add.php">Add tips</a>

<?php
$query = mysql_query("SELECT * FROM `tips`");
$display = mysql_fetch_array($query);
?>

<b>Tips</b><br />
<a href="view.php?id=<?php echo $display['id']; ?>"><?php echo $display['name']; ?></a>view.php


<?php
require_once("config.php");

$getid = $_GET['id'];
$query = mysql_query("SELECT * FROM `tips` WHERE `id` = '".$getid."'");
$display = mysql_fetch_array($query);

echo $display['name'] . "by:" . $display['author'] . "<br />" . $display['content'];
?>
add.php


<?php
require_once("config.php");

if($_GET["action"] == "submit"){
$name = clean($_POST['name']);
$author = clean($_POST['author']);
$content = clean($_POST['content']);

if($name == ""){
echo "You forgot a title";
}

if($author == ""){
echo "You forgot your name";
}

if($content == ""){
echo "You forgot your content";
} else { ?>
Thanks for adding your tip, you may view it <a href="view.php?id="<?php $display['id']; ?>">here</a>
<?php
}
}
?>

<form method="post" action="action?submit">
Tip name:
<input type="text" name="name">

Author (your name):
<input type="text" name="author">

Content:
<input type="text" name="content">
</form>
config.php


$database = array();

$database['host'] = 'localhost';
$database['name'] = 'dbname';
$database['user'] = 'dbuser';
$database['pass'] = 'dbpw;

$mysql_connection = mysql_pconnect($database['host'], $database['user'], $database['pass']);

mysql_select_db($database['name'], $mysql_connection);

function clean($s){
$s = addslashes($s);
$s = htmlspecialchars($s,ENT_QUOTES);
return $s;
}
I haven't actually ran the code on my server, so there may be some errors.

Calon
29-07-2008, 08:22 PM
First create a database name tips, with whatever username and password you desire. (remember to edit the MySql details in config.php with your username and password). Then in that database, run the following query:


CREATE TABLE `tips` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 25 ) NOT NULL ,
`author` VARCHAR( 35 ) NOT NULL ,
`content` TEXT NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM
Now here's the codes for each page:

index.php

<?php
require_once("config.php");
?>

<a href="add.php">Add tips</a>

<?php
$query = mysql_query("SELECT * FROM `tips`");
$display = mysql_fetch_array($query);
?>

<b>Tips</b><br />
<a href="view.php?id=<?php echo $display['id']; ?>"><?php echo $display['name']; ?></a>view.php


<?php
require_once("config.php");

$getid = $_GET['id'];
$query = mysql_query("SELECT * FROM `tips` WHERE `id` = '".$getid."'");
$display = mysql_fetch_array($query);

echo $display['name'] . "by:" . $display['author'] . "<br />" . $display['content'];
?>
add.php


<?php
require_once("config.php");

if($_GET["action"] == "submit"){
$name = clean($_POST['name']);
$author = clean($_POST['author']);
$content = clean($_POST['content']);

if($name == ""){
echo "You forgot a title";
}

if($author == ""){
echo "You forgot your name";
}

if($content == ""){
echo "You forgot your content";
} else { ?>
Thanks for adding your tip, you may view it <a href="view.php?id="<?php $display['id']; ?>">here</a>
<?php
}
}
?>

<form method="post" action="action?submit">
Tip name:
<input type="text" name="name">

Author (your name):
<input type="text" name="author">

Content:
<input type="text" name="content">
</form>
config.php


$database = array();

$database['host'] = 'localhost';
$database['name'] = 'kolzy_ws';
$database['user'] = 'kolzy_w';
$database['pass'] = 's';

$mysql_connection = mysql_pconnect($database['host'], $database['user'], $database['pass']);

mysql_select_db($database['name'], $mysql_connection);

function clean($s){
$s = addslashes($s);
$s = htmlspecialchars($s,ENT_QUOTES);
return $s;
}
I haven't actually ran the code on my server, so there may be some errors.
For a tiny script, 4 pages?

You could have just used $_GET for view/add.

wsg14
29-07-2008, 08:24 PM
For a tiny script, 4 pages?

You could have just used $_GET for view/add.

Meh, I like having my pages spread out. I don't like everything being cluttered. And you never know, he might build off of it so you would not want the config on the index page.

Source
29-07-2008, 09:18 PM
BOX! is new to coding, so let him find his own way. His code looks promising though as he is working it all out pretty quickly.

When saydev opens hopefully all the things we have on there will bring him up to a nice high standard, he has alot of potential.

But BOX! you will find out that it will be so much easier to use a less amount of files on bigger scripts :)

wsg14
29-07-2008, 09:32 PM
BOX! is new to coding, so let him find his own way. His code looks promising though as he is working it all out pretty quickly.

When saydev opens hopefully all the things we have on there will bring him up to a nice high standard, he has alot of potential.

But BOX! you will find out that it will be so much easier to use a less amount of files on bigger scripts :)

Yeah, I'm sure SayDev will help me a lot with my PHP.

When I get to bigger scripts I'll start getting use to using a smaller amount of files.

Calon
29-07-2008, 09:36 PM
BOX! is new to coding, so let him find his own way. His code looks promising though as he is working it all out pretty quickly.

When saydev opens hopefully all the things we have on there will bring him up to a nice high standard, he has alot of potential.

But BOX! you will find out that it will be so much easier to use a less amount of files on bigger scripts :)
I'm new to coding.. he's probably better than me even, but my the way I set my code out is neater than his.

wsg14
29-07-2008, 09:40 PM
I'm new to coding.. he's probably better than me even, but my the way I set my code out is neater than his.

It may be, but we all have different ways of coding and that is mine. I will learn differently (code neater) as I progress.

Calon
29-07-2008, 09:43 PM
It may be, but we all have different ways of coding and that is mine. I will learn differently (code neater) as I progress.
Fair enough. :P

Dudey!
02-08-2008, 07:49 PM
where do i put the actual code? on the webpage?

Dudey!
05-08-2008, 10:52 AM
Hi

I'm having trouble still..

I created the database, with 2 fields, "author" and "tips, and put the code on the webpage, published, and it came out like this;
http://img380.imageshack.us/img380/8200/helprm0.png (http://imageshack.us)

This is what the database and fields look like;
http://img261.imageshack.us/img261/9288/help2op5.png (http://imageshack.us)


I'm really stuck, any help please?

Want to hide these adverts? Register an account for free!