Need help- Will pay

Conmiro

New Member
Messages
140
Reaction score
0
Points
0
When ever I load a certain page on my website, I get this message:

http://conmiro.com/submit.php

Here is the script of submit.php:

<?php
$con = mysql_connect("localhost","conmiro_conmiro","****************");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("my_db", $con);mysql_query
("INSERT INTO websites (sitename, description, email)
VALUES ('$_POST["age"]', '$_POST["age"]', '$_POST["age"]')");
mysql_close($con);
?>


If you can help me, il give you some points.
Edit:
VALUES ('$_POST["age"]', '$_POST["age"]', '$_POST["age"]')");

Thats line 8.
 
Last edited:

VPmase

New Member
Messages
914
Reaction score
1
Points
0
I suggest you replace your password and username with *****'s
 

Conmiro

New Member
Messages
140
Reaction score
0
Points
0
there i fixed my password, i accidently added a space. Does that help more?
Edit:
oh, replace it. Oops. :D My bad. Sooo can you help?
 
Last edited:

Nahid_hossain

New Member
Messages
28
Reaction score
0
Points
0
Here is the corrected code

PHP:
<?php

$con = mysql_connect("localhost","conmiro_conmiro","***** ***********");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
mysql_query("INSERT INTO websites (sitename, description, email) VALUES('".$_POST["age"]."', '".$_POST["age"]."', '".$_POST["age"]."')");
mysql_close($con);
?>
 

exemption

New Member
Messages
66
Reaction score
0
Points
0
First of all you do not need 3 $_POST actions

PHP:
 <?php 

$con = mysql_connect("localhost","conmiro_conmiro","***** ***********"); 
if (!$con) 
{ 
die('Could not connect: ' . mysql_error()); 
} 
mysql_select_db("my_db", $con); 
mysql_query("INSERT INTO websites (sitename, description, email) VALUES('".$_POST["age"]."')"); 
mysql_close($con); 
?>

Corrected code
 
Last edited:

mattura

Member
Messages
570
Reaction score
2
Points
18
perhaps you meant:
$_POST['sitename'], $_POST['description'], and $_POST['email'] or similar?
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
Here is the final complete code.
I edited it a bit so that you may use it and put your personal info without modifying the handling code. I also removed a whitespace at the beginning that could ruin your script.
PHP:
<?php

$db_host = "localhost"; //keep the same
$db_user = "conmiro_conmiro"; //this is your username
$db_pass = "PUT PASSWORD HERE"; //this is your pasword
$db_name = "conmiro_PUT DATABASE NAME HERE"; //this is your database name. it starts by conmiro_
// change the name between the brackets [' '] to what you want i.e sitename , description , email
$values = array($_POST['age'], $_POST['age'], $_POST['age']);

//You do not need to edit below
$query = "INSERT INTO websites (sitename, description, email) VALUES('" . $values[0] . "', '" . $values[1] . "', '" . $values[2] . "')"

$con = mysql_connect($db_host, $db_user, $db_pass); 
if (!$con) 
{ 
die('Could not connect: ' . mysql_error()); 
} 
mysql_select_db($db_name, $con);

mysql_query($query);

mysql_close($con); 
?>
 
Top