PDA

View Full Version : Question...


Radon3k
11-05-2002, 02:44 PM
Ok I have a page where user's can enter their information and once submitted, it takes them to a page where they can see their information along with everyone else who has submitted information.

I have a seperate admin page that will allow me to edit this info, however, I'm not sure if I want to use the ALTER TABLE command or just UPDATE to change specific information such as this:

Name: John Doe


What if I want to change it so it says "John" only? How do I do that?

Thanks :)

Xenon
11-05-2002, 03:48 PM
well, you want to change the field name, so you have to use the update function:

UPDATE tablename SET Name='John' WHERE Name='John Doe'

Radon3k
11-05-2002, 04:16 PM
That's what I thought, but I wasn't sure. Thanks! :)

Radon3k
11-05-2002, 04:31 PM
Instead of SET Name='John' WHERE Name='John Doe'

Could you do this instead?SET Name='$newname' WHERE Name='$Name'

?

Xenon
11-05-2002, 05:07 PM
yes, it is possible, but you should use this:

SET Name='".addslashes($newname)."' WHERE Name='".addslashes($Name)."'

Radon3k
11-05-2002, 05:12 PM
Ok, thanks. Now the problem is that the variable $Name isn't declared in this PHP file, it's declared in another one. How do I make it to where it still works?

Thanks for the help, sir! :)

Radon3k
11-05-2002, 05:14 PM
Btw, does this look right?

if ($submitnewname == "Submit") {
$sql = "UPDATE yp SET Name='"./($newname)."' WHERE Name='"./($Name)."'";

Xenon
11-05-2002, 07:26 PM
first question: hmm, if you include the file it would work, or you can call the script with a command line variable:
script.php?name=blabla

if you call the script through an inputform use this in the form:
<input type="hidden" name="name" value="which name....">

and no, this would be correct:
if ($submitnewname == "Submit") {
$sql = "UPDATE yp SET Name='".addslashes($newname)."' WHERE Name='".addslashes($Name)."'";

the function is called addslashes ;)

Radon3k
11-05-2002, 07:41 PM
Ok I don't understand what you were saying about my first question (regarding how the variable isn't in this particular script).

As of right now I'm using the require() function, and don't see the difference between require() and include().

Don't understand the point of something like "script.php?name=blabla" or how it would be used in context to what I'm working with. The hidden input also confuses me.

Sorry, I'm still learning this stuff, doing the best I can, I appreciate all of your help, sir! :)

Radon3k
11-05-2002, 07:45 PM
Ok well I've got problems galore, allow me to show you the actual page I'm working on. http://radon3k.bbadmins.com/index.php is the main page, there's a link to the second page, and http://radon3k.bbadmins.com/admin.php is where I'd edit the information.

Here's the problem:

I want to edit a specific user name, so if let's say I wanted to change Ryan to Radon3k, how do I do this? I have the general idea, but my code is saying "change all the current names to the name I just typed into the admin name change box".

Does this make sense or am I just confusing myself and everyone else?

Erwin
11-05-2002, 07:53 PM
If you want to change the username, why not just do it in the Admin CP? Or is this totally separate from the vB database?

Radon3k
11-05-2002, 07:57 PM
Sorry, this has nothing to do with vBulletin. I'm going to make something that incorporates into vBulletin, but first it's helpful if I have an understanding of the language. :)

This is also on it's own database.