Reply to on input form showing error message for duplicate entry.

Your name:

Reply:


Posted by linda on 10/16/06 21:04

I very new to php could someone please explain how to write an error message
into my AddNew.php below. id is set to unique so at the moment if someone
adds a product and the id is already in the database, it just doesn't enter
anything. Ideally I would like to display an error message, with a back
button to correct the id.

So far I've tried running a SELECT query with an if statement prior to the
INSERT but I just don't know enough php to get this to work. I would be
very greatful for any info and advice from those in this newsgroup.

Many, many thanks in advance,
Linda


[php]
<?php

//login details


@mysql_connect($host,$user,$password) or die("Unable to connect with
server!");
@mysql_select_db($database)or die("Unable to connect database, please try
later!");

$id=mysql_real_escape_string($_POST['id']); //This is set to unique
$name=mysql_real_escape_string($_POST['name']);
$info=mysql_real_escape_string($_POST['info']);
$pic=mysql_real_escape_string($_POST['pic']);
$lg_pic=mysql_real_escape_string($_POST['lg_pic']);
$price=mysql_real_escape_string($_POST['price']);

$query = "INSERT INTO floral VALUES
('$id','$name','$info','$pic','$lg_pic','$price')";
mysql_query($query);
header("Location: added.php");

mysql_close();
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация