Hi, I have found this forum very useful so far so I was hoping someone could offer me some help again as I have run out of ideas.

Basically here is my code:

addcontact.php

</head>
<body>
<div id="container">
	<div id="header">
	<table width="980px">
	<tr>
	<td align="left"><img src="images/lcaclogo.gif" width="100px" height="100px"></td>
	<td><h1>LCAC Administration</h1></td>
	</tr>
	</table>
	</div>
	<div id="navigation"><ul><li>Add Contact</li></ul></div>
	<div id="content-container">
	<div id="section-navigation">
	<ul>
		<li><a href="index.php">Home</a></li>
		<li><a href="contactlistadmin.php">Contact List Admin</a></li>
		<li><a href="logout.php">Log Out</a></li>
	</ul>
	</div>
	<div id="content">
<center><p><b>Add A Contact</b><p></center>
<center>
<form enctype="multipart/form-data" name="addcontact" action="processaddcontact.php" mehtod="get">
<fieldset>
<legend>Name</legend>
<label class="label">Title</label> <input type="text" name="title"><br>
<label class="label">Firstname</label> <input type="text" name="firstname"><br>
<label class="label">Surname</label> <input type="text" name="surname"><br>
</fieldset>
<fieldset>
<legend>Address</legend>
<label class="label">House No/Name</label> <input type="text" name="house"><br>
<label class="label">Street</label> <input type="text" name="street"><br>
<label class="label">Town/City</label> <input type="text" name="town"><br>
<label class="label">County</label> <input type="text" name="county"><br>
<label class="label">Country</label> <input type="text" name="country"><br>
<label class="label">Zip/Postcode</label> <input type="text" name="postcode">
</fieldset>
<fieldset>
<legend>Internet</legend>
<label class="label">Email</label> <input type="text" name="email"><br>
<label class="label">Website</label> <input type="text" name="website">
</fieldset>
<fieldset>
<legend>Telephone Numbers</legend>
<label class="label">Home</label> <input type="text" name="home"><br>
<label class="label">Mobile</label> <input type="text" name="mobile"><br>
</fieldset>
<fieldset>
<legend>Parish</legend>
<label class="label">Parish</label> <input type="text" name="parish"><br>
<label class="label">Additional Info</label> <input type="text" name="additionalinfo">
</fieldset>
<fieldset>
<legend>Photo</legend>
<label class="label">Photo</label> <input type="file" name="photo">
<br>
<input class="submit" name="submit" type="submit" value="Add Contact">
<br>
</form>
</center>
</div>
	<div id="footer">Copyright &copy LCAC, 2011</div>
</div>
</body>
</html>

processaddcontact.php

<?php
	session_start();
	require "connect.php";

        $target = "images/";
	$target = $target . basename( $_FILES['photo']['name']);

	$title= $_GET['title'];
	$firstname= $_GET['firstname'];
	$surname= $_GET['surname'];
	$house= $_GET['house'];
	$street= $_GET['street'];
	$town= $_GET['town'];
	$county= $_GET['county'];
	$country= $_GET['country'];
	$postcode= $_GET['postcode'];
	$email= $_GET['email'];
	$website= $_GET['website'];
	$home= $_GET['home'];
	$mobile= $_GET['mobile'];
	$parish= $_GET['parish'];
	$moreinfo= $_GET['additionalinfo'];
	$photo = ($_FILES['photo']['name']);

	$query = "insert into contacts values(0,
	'".$title."',
	'".$firstname."',
	'".$surname."',
	'".$house."',
	'".$street."',
	'".$town."',
	'".$county."',
	'".$country."',
	'".$postcode."',
	'".$email."',
	'".$website."',
	'".$home."',
	'".$mobile."',
	'".$parish."',
	'".$moreinfo."',
	'".$photo."')";

	$result = mysql_query($query, $connection)
	or die ("Unable to perform query<br>$query");

	//Writes the photo to the server
	if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
	{

	//Tells you if its all ok
	echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
	}
	else {

	//Gives and error if its not
	echo "Sorry, there was a problem uploading your file.";
	}
?>
?>

I have tried to get this to work so that I can add the filename and then add it to the database and upload the file to server but i keep getting these errors

Notice: Undefined index: photo in C:\xampp\htdocs\Clergy\processaddcontact.php on line 6

Notice: Undefined index: photo in C:\xampp\htdocs\Clergy\processaddcontact.php on line 23

Notice: Undefined index: photo in C:\xampp\htdocs\Clergy\processaddcontact.php on line 47
Sorry, there was a problem uploading your file.

I really need someone else to look at this and see what I am doing wrong
Any help would be much appreciated

Thanks in advance

Recommended Answers

All 6 Replies

2 things. change your method (form method='get') to post.
and then in your php page (lines 8 - 23) change $_GET to $_POST.
also, line 51 $_FILES) needs to be

$_FILES['photo']['name']

Use POST method. Never use GET with user informations. Remove the bracket at line 23.

$photo = ($_FILES);

Use instead above:

$photo = $_FILES['photo']['name'];

Use POST method. Never use GET with user informations. Remove the bracket at line 23.

$photo = ($_FILES);

Use instead above:

$photo = $_FILES['photo']['name'];

I have made the alterations as suggested but i am still getting the same errors, can someone help or direct me to a site to do what I want to do a different way.

Thanks
Chris

is it:
$photo = $_FILES;
?

you have mispelled 'method' on your form tag mehtod="get"> and it should be method="post".
make these changes. you cannot be getting the same errors. what are your errors now?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.