-2

When I run the following PHP code in my browser, I get an empty page in return. Why is this so?

<?php 

require_once "conf.php";

function nuser()
{
    $fname = $_POST['name'];
    $uname = $_POST['user'];
    $email = $_POST['email'];
    $pass = $_POST['pass'];
    $query = "INSERT INTO websign(name,uname,email,pass)VALUES('$fname','$user','$email','$pass')";
    $data = mysql_query($query)or die(mysql_error());
    if ($data)
    {
        echo "your registration is completed";
    }
}
function signup()
{
   .......
   .......
}
?>
Philipp Maurer
  • 2,480
  • 6
  • 18
  • 25
  • 3
    Your script is vulnerable to SQL-injection. Never ever trust and use user-submitted data in your queries. Also, please extend your question with error messages (maybe you can found them in logs). – fabrik Sep 24 '18 at 09:56
  • A php function will run when you call it, where do you call `nuser()`? Where the `$_POST` came from? And you shouldn't use mysql_query, it's deprecated : http://php.net/manual/en/function.mysql-query.php – Mickaël Leger Sep 24 '18 at 09:58
  • In your given sample code you are using 2 functions. But, from nowhere you are calling those functions. So, nothing is executing & due to nothing is there to show up. – Suresh Sep 24 '18 at 10:01
  • You don't _actually_ have raw passwords saved in your database do you? – mickmackusa Sep 24 '18 at 11:51

1 Answers1

1

Your code doesn't do anything.

You have defined two functions, but you never call either of them.

You need to add nuser() to the end of the script.


This assumes that the script executes at all. You said "when i run it on browser", but PHP doesn't run in browsers, it runs on servers. See this question on the subject.


Your program might also fail because you are using an obsolete database API that has been removed from PHP. You should select a modern replacement. You are vulnerable to SQL injection attacks that a modern API would make it easier to defend yourself from.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335