Hello everyone, I am trying to update a database as well as insert information into the database and this is what I created to do so. Only, I am getting the email and its not updateding the database...any ideas?

if ($_POST['submit']) //if the Submit button pressed
                      $con = mysqli_connect("localhost","root","pass","testdb");
                       if (mysqli_connect_errno())
                                      echo "Failed to connect to MySQL:" . mysqli_connect_error();

$sql = "INSERT INTO computerdb (name, email, ticket, phone, computerpass, findus, status, notes )
                       VALUES ('".mysqli_real_escape_string($con,$_POST['name'])."','".mysqli_real_escape_string($con,$_POST['email'])."','".mysqli_real_escape_string($con,$_POST['ticketnumber'])."','".mysqli_real_escape_string($con,$_POST['phone'])."','".mysqli_real_escape_string($con,$_POST['password'])."','".mysqli_real_escape_string($con,$_POST['referredby'])."', 'Pending', '".date('m/d/Y H:i:s'). ": Work has started on your computer')";

                       if (!mysqli_query($con,$sql))
                             die('Error: ' . mysqli_error($con));
                                $blah = $_GET['computerid'];
                                $cpuname    =    mysqli_real_escape_string($con,$_POST['cpuname']);
                                $sn          =    mysqli_real_escape_string($con,$_POST['sn']); 
                                $model    =    mysqli_real_escape_string($con,$_POST['model']);
                                $brand       =    mysqli_real_escape_string($con,$_POST['brand']);
                                $hdd    =    mysqli_real_escape_string($con,$_POST['hdd']);
                                $memory    =    mysqli_real_escape_string($con,$_POST['memory']);
                                $type    =    mysqli_real_escape_string($con,$_POST['type']);

                             $query = "UPDATE custcomp SET cpuname = '$cpuname', sn = '$sn', model = '$model', brand = '$brand', hdd =  '$hdd', memory = '$memory', type = '$type' WHERE id = '$blah'";

                             if (!mysqli_query($con,$query))
                                die('Error: ' . mysqli_error($con));

            //if data is inserted successfully, send email
                       $to = $_POST['email'];
                       $url = "http://omitted.com/newportal/do_search.php?query=";
                       $ticket = $_POST['ticketnumber'];

                       $header = 'MIME-Version: 1.0' . "\r\n";
                        $header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
                        $header .= "From: omitted. <tickets@omitted.com>" . "\r\n";
                       $subject = "Ticket Number ".$_POST['ticketnumber'];
                       $body .= "<html><body>"."\n";
                    $body .= "Hello ".$_POST['name'].",<br>
                    $body .= "Thank you for stopping by today.<br><br>"."\n";
                    $body .= "The information below is used to check on the status of your computer.<br>"."\n";
                    $body .= "Check Computer Status: <a href=\"".$url.$ticket."\">".$ticket."</a><br><br>"."\n";
                    $body .= "Be sure to like us on <a href=\"http://www.facebook.com/omitted\"><img                                                                                                              src=\"http://www.omitted.com/ticketgen/images/facebook.png\" width=\"30\" height=\"30\"></a> and <a href=\"http://www.twitter.com/omitted\"><img src=\"http://www.omitted.com/ticketgen/images/twitter.png\" width=\"50\" height=\"30\"></a>!". "\n";
                    $body .= "<br><br><br>Sincerly, <br><br><img style=\"border:none; text-decoration:none;\" src=\"http://www.omitted.com/ticketgen/images/signature.png\" alt=\"Patrick Kershner\" />"."\n";
                    $body .= "</html></body>"."\n";
                       $sent = mail($to, $subject, $body, $header);
                               header('Location: http://www.omitted.com/newportal/new_ticket.php?success=1&redir=1');
                               {print "There was an error sending the mail";}

Re: Will not update or insert, but get email from the code 80 80

I think I figured out what is going on...In the code for HTML I have a dropdown that they select the computer from and modifies the code after its already been generated. Since the code is not present during the initial loading period, it therefore does not exist. I am now unsure of how to get the code to read the modified html code that gets generated afterwards.

Be a part of the DaniWeb community

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