Jump to content

DIRE NEED OF HELP, NEWBIES GOT PROBLEMS!!


devang23

Recommended Posts

So i set up a table in mysql on webhost.com

but i cant get this script to work correctly, could it be because i dont have the right "sql="?

anyone know what i can do?

<html><head><title>Adding a User </title></head>
<body>
<?php
if( (!$firstname) or (!$lastname) or (!$username) or (!$password) )
{
$form ="Please enter all new user details";
$form.="<form action=\"$PHP_SELF\"";
$form.=" method=\"post\">First Name: ";
$form.="<input type=\"text\" name=\firstname\"";
$form.=" value=\"$firstname\"><br>Last Name: ";
$form.="<input type=\"text\" name=\"lastname\"";
$form.=" value=\"$lastname\"><br>UserName: ";
$form.="<input type=\"text\" name=\"username\"";
$form.=" value=\"$username\"><br>PassWord: ";
$form.="<input type=\"text\" name=\"password\"";
$form.=" value=\"$password\"><br>";
$form.="<input type=\"submit\" value=\"Submit\">";
$form.="</form>";
echo($form);
}
else
{ $conn = @mysql_connect("mysql4.000webhost.com") or die("Try Again Punk");
  $db = @mysql_select_db("a3213677_snorre", $conn) or die("NOOPE")
  $sql = "insert into users table(first_name,last_name,user_name,password) values(\"$firstname\",\"$lastname\",\"$username\",password(\$password\") )";
  $result = @mysql_query($sql,$conn) or die ("NOT EVEN")
  if($result) { echo("New User $username ADDED DUH!") ; }

}
?> </body></html>

EDIT: We got CODE tags.

Link to comment
Share on other sites

did you mean like this

<html><head><title>Adding a User </title></head>
<body>
<?php
if( (!$firstname) or (!$lastname) or (!$username) or (!$password) )
{
$form ="Please enter all new user details";
$form.="<form action=\"$PHP_SELF\"";
$form.=" method=\"post\">First Name: ";
$form.="<input type=\"text\" name=\firstname\"";
$form.=" value=\"$firstname\"><br>Last Name: ";
$form.="<input type=\"text\" name=\"lastname\"";
$form.=" value=\"$lastname\"><br>UserName: ";
$form.="<input type=\"text\" name=\"username\"";
$form.=" value=\"$username\"><br>PassWord: ";
$form.="<input type=\"text\" name=\"password\"";
$form.=" value=\"$password\"><br>";
$form.="<input type=\"submit\" value=\"Submit\">";
$form.="</form>";
echo($form);
}
else
{ $conn = ("mysql4.000webhost.com") or die("Try Again Punk");
  $db = ("a3213677_snorre",$conn) or die("NOOPE")
  $sql = "insert into users table(first_name,last_name,user_name,password) values(\"$firstname\",\"$lastname\",\"$username\",password(\$password\") )";
  $result = ($sql,$conn) or die ("NOT EVEN")
  if($result) { echo("New User $username ADDED DUH!") ; }

}
?> </body></html>

EDIT: Again. we got

...some code...

tags..

Link to comment
Share on other sites

no... that's not what I meant

By doing that you just removed the functions flat out.. which would leave your script doing nothing whatsoever.

 

This is what I meant

$conn = @mysql_connect("mysql4.000webhost.com") or die("Try Again Punk");

 

Also... you can actually find the exact reason something doesn't work if you use the mysql_error function

$conn = @mysql_connect("mysql4.000webhost.com") or die("This is your error: ->  " . mysql_error());

Link to comment
Share on other sites

hang on, the first time i sent it, it had the @s, i dont understand why it wont connect to mysql tables in my database that is set up on third party server

Consider it from this perspective.  Imagine that third party server wasn't yours.  Better yet, let's assume it is yours still.  Now, lets say I use the same script you wrote to connect to your database.

 

Should I be allowed to do this? No.

 

That is why MySQL is set up in such a way that you have to tell the server whom will be connecting to it... and from where they will be connecting.

 

This is the part where you tell us how you manage your third party mysql server so that we can inform you how to ALLOW YOURSELF to connect to it from YOUR "AUTHORIZED" server.

Link to comment
Share on other sites

hang on, the first time i sent it, it had the @s, i dont understand why it wont connect to mysql tables in my database that is set up on third party server

Consider it from this perspective.  Imagine that third party server wasn't yours.  Better yet, let's assume it is yours still.  Now, lets say I use the same script you wrote to connect to your database.

 

Should I be allowed to do this? No.

 

That is why MySQL is set up in such a way that you have to tell the server whom will be connecting to it... and from where they will be connecting.

 

This is the part where you tell us how you manage your third party mysql server so that we can inform you how to ALLOW YOURSELF to connect to it from YOUR "AUTHORIZED" server.

 

 

 

okay say i was using a regular mysql, i set up a table called User Table, how would i allow information outside my database to be inserted into my database.... what would i do on mysql that will allow that?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.