# PHP Code not working. And hell I just don't know why!?

**URL:** <https://forum.kirupa.com/t/php-code-not-working-and-hell-i-just-dont-know-why/156825>\
**Category:** programming\
**Created:** [July 28, 2005, 8:10am UTC](https://forum.kirupa.com/t/php-code-not-working-and-hell-i-just-dont-know-why/156825 "2005-07-28T08:10:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Smith](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ben_smith/32/1118_2.png) [@Ben\_Smith](https://forum.kirupa.com/u/Ben_Smith)\
**Post date:** [July 28, 2005, 8:10am UTC](https://forum.kirupa.com/t/php-code-not-working-and-hell-i-just-dont-know-why/156825/1 "2005-07-28T08:10:47Z")

</div>

Hey People,

I was working on my site when I came across some code that should have been easy for me to do, as it’s repeated like twice in the whole thing.

I just don’t know why it doesn’t work.

```php
<?php
//Including configuration file which will contain the username, the password, the host and the database name.
include '../connect.php';
include '../functions.php';
//Declaring all the variables ready for posting
$title = $_POST['title'];
$oldlink = $_POST['link'];
$link = urlcheck($oldlink);
$desc = $_POST['desc'];
$sort = $_POST['sort'];
$type = $_POST['type'];
//Checking if the form is being posted
If (isset($_POST['submit'])){
	mysql_connect($host,$user,$pass);
	mysql_select_db($db);
	$query = "INSERT INTO sidelinks SET link = '" . $link . "',
		        			 title = '" . $title . "',
		        			 desc = '" . $desc . "',
		        			 sort = '" . $sort . "',
		        			 type = '" . $type . "'";
	mysql_query($query);
}
?>
<p class="menu_subtitles">Add an Item </p>
<form action="<?=$PHP_SELF?>" method="post" name="item" class="menu_item" id="item">
Item Title*:<br>
<input class="tbs" name="title" type="text" id="title">
<br>
Item Link*:<br>
<input class="tbs" name="link" type="text" id="link">
<br>
Item Type*:<br>
<input class="tbs" name="type" type="text" id="type" value="1" disabled>
<br>
Item Description*:<br>
<input class="tbs" name="desc" type="text" id="desc">
<br>
Item Sort*:<br>
<input class="tbs" name="sort" type="text" id="sort">
<br>
*Denotes a required field<br>
<input class="submitorclear" name="submit" type="submit" id="submit" value="Add Item">
<input class="submitorclear" type="reset" name="Reset" value="Clear">
</form>

```

Also, when someone/if someone solves this, I’ll post some more code like this that’s also annoying me.

Thanks anyway.  
Benji
