Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #5564
| From | hipa <hipa.invalid@telenet.be> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | php include, function, ... |
| Date | 2012-04-18 20:03 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <jmn6ms$ots$1@speranza.aioe.org> (permalink) |
Hi there
I have a litle page with a form, which inserts an article in a postgres
db with php.
The php code is in the html page. Can someone tell me what the best way
is to exclude the php code from this page. And then just calling it true
a function or something?
<body>
<?php
if(isset($_POST['insertarticle']) && $_POST['insertarticle']){
$dbh = pg_connect("host=..... dbname=..... user=.....
password=.....");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
if(isset($_POST['article'])){
$article = pg_escape_string($_POST['article']);
$sql = "INSERT INTO tblarticle values ((select max(idarticle) + 1 from
tblarticle), '{$article}')";
$result = pg_query($dbh, $sql);
}
{die(pg_last_error());}
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
pg_free_result($result);
pg_close($dbh);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" name="insertarticle" value="Insert Article">
<label>Article:</label> <input id="article" name="article" type="text">
</form>
</body>
Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread
php include, function, ... hipa <hipa.invalid@telenet.be> - 2012-04-18 20:03 +0000
Re: php include, function, ... Redcat <redcat@catfolks.net> - 2012-04-18 20:08 +0000
Re: php include, function, ... hipa <hipa.invalid@telenet.be> - 2012-04-21 06:40 +0000
Re: php include, function, ... Arno Welzel <usenet@arnowelzel.de> - 2012-04-18 22:12 +0200
Re: php include, function, ... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-19 02:55 +0200
Re: php include, function, ... hipa <hipa.invalid@telenet.be> - 2012-04-21 06:46 +0000
Re: php include, function, ... IRC <ircadhikari@gmail.com> - 2012-04-19 03:55 -0700
Re: php include, function, ... IRC <ircadhikari@gmail.com> - 2012-04-19 03:51 -0700
csiph-web