Jump to content

PHP_SQL coding problem-- in wamp server


amitchhajer

Recommended Posts

PLZ help me with this code...hav sum coding prblem

m making a form 2 input values in a database..plz reply asap m a noob

 

 

hi ur data is being processed and your account will be activated within 24hrs

 

<?php

$a=htmlspecialchars($_POST['name']);

$b=htmlspecialchars($_POST['fname']);

$c=htmlspecialchars($_POST['lname']);

$d=htmlspecialchars($_POST['pass']);

$e=htmlspecialchars($_POST['pass2']);

$f=htmlspecialchars($_POST['sques']);

$g=htmlspecialchars($_POST['sans']);

$h=htmlspecialchars($_POST['smail']);

$i=htmlspecialchars($_POST['location']);

?>

 

Thanks for registering

 

 

<?php

$con = mysql_connect();

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("amit", $con);

$sql="INSERT INTO LOGIN

VALUES('$_POST[Choose LOGIN name]','$_POST[First name]','$_POST[Last name]','$_POST[Choose a Password]','$_POST[Re-enter Password]','$_POST[security Question]','$_POST[Answer]','$_POST[secondary email]','$_POST[Location]');

 

if (!mysql_query($sql,$con))

  {

  die('Error: ' . mysql_error());

  }

echo "1 record added";

 

mysql_close($con)

?>

Link to comment
https://forums.phpfreaks.com/topic/153536-php_sql-coding-problem-in-wamp-server/
Share on other sites

I got this error in the program:::

 

 

Parse error: parse error, expecting `']'' in C:\wamp\www\New Folder\actionlogin.php on line 27

 

 

i dont know wat is credential..

 

i made a form using form action in php

and want to connect it to database

links to both files:-

http://www.mediafire.com/?sharekey=45cc7f380b7ea8cd1bee9a6e9edd9c76edd7e379ccbffa5cc95965eaa7bc68bc

 

 

 

plz do reply

When using the post array with strings you need to quote the string (key) in the array, also single quotation marks are for literal data.

 

Example.

$user = 'John Wayne';

echo 'Hello $user';

// Outputs Hello $user

echo "Hello $user";

// Outputs Hello John Wayne

 

Also I tend to break out of the string for echoing a variable and use mysql_real_escape_string() when inserting postdata into your database. Never insert raw postdata.

 

 

// EDIT *

 

Also please use code tags when posting code.

 

[*code*][*/code*]

 

Remove the asterix tho.

I don't believe quoting post arrays is a necessity, although it is faster.

$_POST[whatever]; and $_POST['whatever']; both achieve the same results, though the latter is preferred.

And yes, mysql data should be escaped; I was just wondering if it actually solved his problem first :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.