MYSQL update through PHP form - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-15-2009, 06:02 AM   #1 (permalink)
Junior Member
 
Join Date: Mar 2009
Posts: 1
Default MYSQL update through PHP form

I want to use a php form textfield to change a value in my databas. I got this far by im keep getting this error, please help me figure out whats wrong.

PHP Code:
  <?php

 $server 
"localhost";
  
$username "admin";
  
$password "admin";
  
$database "local_db";
  
$con mysql_connect($server$username$password);
  
$ok mysql_select_db($database$con);
      
        
$Cname mysql_real_escape_string($_POST['newname']);

    
$sql "UPDATE people SET name='{$Cname}' WHERE id=1";
    
mysql_query($sql) or die(mysql_error());

        

 
?>


<form method="post" action="">
  
    <input name="newname" type="text" id="textfield"/>
    
    <input type="submit" name="change" value="Change now" />
    
</form>

<?php
if(isset($_POST['change'])){
    if(!
preg_match("/^[A-Za-z]$/",$_POST['name'],$match)){
        echo 
"Invalid characters, please try again";
            }
    if(
preg_match("/^[A-Za-z]$/",$_POST['name'],$match)){
       
header('Location: http://localhost/sent.php');
        
}
}
?>
Notice: Undefined index: newname in this line,

PHP Code:
$Cname mysql_real_escape_string($_POST['newname']); 

Last edited by Codethat; 03-15-2009 at 06:08 AM.
Codethat is offline   Reply With Quote
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:40 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting