/    Sign up×
Community /Pin to ProfileBookmark

Form question

Hello. I have this little form as you can se from “form.php” what i wonder is for “add.php”, what should i have in [B]“$news =;[/B] and [B]$name = ;[/B]” to make it enter what’s writen in those forms called “news & name” to the database?

[B]form.php[/B]

[code=html]<form enctype=”multipart/form-data” action=”add.php” method=”POST”>
<div align=”center”>
Manga Plum news section<br><br>
<textarea cols=”40″ rows=”5″ name=”news”>
Type your news here
</textarea>
</div>
name: <input type=”text” name=”name” size=”22″><br>
<input type=”submit” value=”Add”>
</p>
</form>[/code]

[B]add.php[/B]

[code=php]<?php
error_reporting(E_ALL);

//This gets all the other information from the form
$news = ;
$date = date(‘Y-m-d’);
$name = ;

// Connects to your Database
mysql_connect(“localhost”, “user”, “password”) or die(mysql_error()) ;
mysql_select_db(“database”) or die(mysql_error()) ;

//Writes the information to the database
mysql_query(“INSERT INTO `table` VALUES (”,’$news’,’$date’,’$name’)”) or die(mysql_error());

echo “News published and your information has been added to the Database”;

?>[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@thraddashOct 11.2009 — If you are simply asking how to retrieve the information sent from the form, then you can use:

[CODE]$news = $_POST['news'];
$name = $_POST['name'];[/CODE]
×

Success!

Help @izlik spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...