# Redirection when submitting a form

**URL:** https://forum.kirupa.com/t/redirection-when-submitting-a-form/207265
**Category:** Uncategorized
**Created:** [November 16, 2006, 2:19am UTC](https://forum.kirupa.com/t/redirection-when-submitting-a-form/207265 "2006-11-16T02:19:19Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![AlexGM16](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@AlexGM16](https://forum.kirupa.com/u/AlexGM16)
#### Post date: [November 16, 2006, 2:19am UTC](https://forum.kirupa.com/t/redirection-when-submitting-a-form/207265/1 "2006-11-16T02:19:19Z")

</div>

```php
<form name="toSave" method="post"
action="<?=$_SERVER['PHP_SELF']?>">
<input type="text" name="title" size="20" /><br> 
<input type="text" name="newstext" size="20" />
<input type="submit" name="submit" value="submit" />
 </form> 

<?php
$db=mysql_connect("localhost", "user", "pass") or die("Could not connect to localhost."); 
mysql_select_db("alex", $db) or die("Could not find database alex");

$querySQL = mysql_query("insert into news (postdate, title, newstext) values (CURDATE(), '".$_POST['title']."', '".$_POST['newstext']."')");
if(!$querySQL) error_message(sql_error());  

?> 

```

I tried to insert an if statement for a header to a different page but they said a header is already in use on line 2…wtf mate?lol
