Page 1 2 

Moderators: Derry, Goldie, Harpo
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Working Mechanic
Posted
I came across this: http://www.swish-db.com/tutorials/view.php/tid/601
and would like to install it on my website. The forms are no problem, but where and how do I put the php code (I am using IhostVm) and the database? do I need php and mysql on my computer or is this all done in the control panel of the host? All i am trying to do is to have a registration and log in form with a database of users on my website.
Thanks for any help
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
I took a quick look trough the tutorial. First, you will need to use your host account control panel option to set up a database. The steps needed to create a database differ from host to host, but look for a tool named phpMyAdmin. This will let you create a database. Some hosts require you to use a database set-up tool before you can use phpMyAdmin; check the host's FAQs and help section for the correct procedure.

Once you have set up the database (and make sure you keep a record of the user and password so you can log-in), you will need to create the database table. That's the code following the form code that starts "CREATE TABLE(...". Copy and paste this code into a plain text editor and save it with a file name of create-table.sql so you know what it is. You should be able to use the phpMyAdmin tool to upload and execute this code. If not, then you can use the code statements that defines the table record and use the phpMyAdmin tool to manually create the table.

PHP code executes on a server vs in a browser so you will need to copy & paste the PHP code into a plain text editor and then upload it to you site. A word of warning here. Not all the PHP code displayed in the tutorial is complete; it is broken up into section for explanation purposes. You are interested in the full code at the bottom of the page marked
quote:
That’s it! Now for the full code:

register.php
Copy and paste this code into a plain text editor, save it as register.php and then upload it to your site. Make sure you adjust the PHP code used to log into the database using your real log-in credentials. That would be:
$dbname = "your database name";
$dbuser = "username";
$dbpass = "yourpass";  

This message has been edited. Last edited by: larryd,
 
Posts: 5097 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
thanks for the quick reply larryd. I will give it a go and let you know.SS and the forum are great
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
quote:
register.php

thanks larryd
allseemed to be ok until i tried to run it after publishing when i received the following error:Parse error: syntax error, unexpected T_STRING in C:\Inetpub\vhosts\ozboatadvisor.ihostvm.com\httpdocs\register.php on line 24
I understand that it's a syntax error but not being a programmer i have no idea what to look for.
Again your help would be greatly appreciated.
By the way, do you have some sort of advertising for SS as i wouldn't mind promoting it on my website "ozboatadvisor.com
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
I should have made more than a quick look-thru of that code.

There are 2 PHP scripts there:

register.php - used by the registration form

and

login.php - used to allow a user log-in once he/she is registered.

I ran the register.php script with my syntax checker and did not get an error. However, syntax checking the login.php script did produce an error. Sometimes blogging programs will convert typed double-quote characters (") into back-quote and forward-quote characters (“ and ”); also known as smart-quotes. It looks like this is what happened with the log-in.php script. These types of quote marks cannot be used to delimit (indicate) strings (a line of characters), so look through your scripts and replace any you find. A search & replace function should work also.

Line 24 of the pasted register.php script in my editor is blank, so I do not see the error. I do not see a smart-quote problem in any of the strings, so it is some other problem. If you can copy&paste the script directly from your editor (or maybe just lines 20 to 30), I can take a look at what you are uploading.
 
Posts: 5097 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
again thanks for your prompt answer - here is a copy and paste of the lines of register.php

themysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

    
$name = $_POST['name'];
$email = $_POST['email'];    
$username = $_POST['username'];
$password = md5($_POST['password']);

// lets check to see if the username already exists

$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
    echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset($username);
    include 'register.html';
    exit();
}
thanks again
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
I'm not detecting any error in your code. Can youy post a link to your site? Perhaps the problems lies in the form code and what is being passed to the script.
 
Posts: 5097 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
Thank you for all your efforts and here is the link
http://ozboatadvisor.ihostvm.com/index.html#
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
I think you have a problem with your forms. I know in the example that it shows the login form and the register form using the same form name ("login"), but these examples were designed to have the forms on 2 different HTML pages. By having the 2 forms of the same page, the name-values pairs sent by the form when the submit button is clicked is getting mixed up among the 2 forms.

Try changing the form used for registration from "login" to "register" and see if that helps.
 
Posts: 5097 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
thanks, I did that now, but still get the same error. Maybe I have to search for another registration/log in solution unless you have any suggestions.
Thanks again for your great support.
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
That code should work; it is pretty standard and is basically the same code as I use for my own login/registration code.

In your posting of your code with the error above, the line:
quote:

themysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
Is this what is in your code? I had assumed that the "themysql_connect" was a cut&paste error as it should be "mysql_connect" (what the code example shows).

I have loaded and run the register.php script on my system and do not get a parse error. My email address is in my public profile. If you could email me the same php file that you uploaded, I can test it and maybe narrow down the error.

On a side note: you will find SiteSpinner logos in %Program Files%\Virtual Mechanics\SiteSpinner Pro V2\ClipArt
 
Posts: 5097 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
i have downloaded a trial version of a php debugger and run the code through it getting the following error
$query = “select * from users where username=’$username’ and password=’$password’”; where users is underlined "unexpected 'string' unexpected 'users'" in line 91
i don't understand what they mean
thanks and i will email you the code
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
I got your file, but could not open it as a text file - I'm not sure what it is.
quote:
$query = “select * from users where username=’$username’ and password=’$password’”;
It should be
quote:
$query = "select * from users where username='$username' and password='$password'";
I see smart-quotes being used in this PHP statement and also back-ticks being used in place of a single quote mark. Go through this statement and replace all double-quotes with double-quotes and all single-quotes with single-quotes; ignore what the characters look like on the screen, just re-type each double and single quote character to make sure the proper character is being used.

What text editor are you using? Strange the cut&paste into my editor did not convert those characters and yours did.
 
Posts: 5097 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
thanks for that and i will retype all the quotes as you suggested. I am using open office 'writer'
it may take me a few days to complete the above as i am back at work again, but will report as soon as i am done
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Honorary Mechanic
Picture of Kirk
Posted Hide Post
If you're going to be working with php, you might want to think about getting something other than a plain text editor. There are many code editors out there that are either free, shareware or commercial. Most include syntax highlighting as well as global change capability (which it sounds like you need).

I did a quick search and came up with this link to a freeware editor that looks pretty good.
 
Posts: 211 | Registered: July 22, 2007Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
first larryd
i went through the code and replaced every ' and " but still get the same error
Parse error: syntax error, unexpected T_STRING in C:\Inetpub\vhosts\ozboatadvisor.ihostvm.com\httpdocs\register.php on line 29
if it worked with you maybe a copy of yours might work
Kirk - thanks for your effort also, I wish all forums where as fantastic as this one! I looked up the site you suggested but got confused as to what to download and use
Thank you all, would love to get this bit working on my website and hope to be able to reciprocate in the future
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Honorary 'Aussie' Mechanic
Picture of postyr
Posted Hide Post
I am not aware of Office Writer, but as Larry says, you need to use a text editor (not a word formatting program) to eliminate the smart quotes.

The two most popular programs for that are Notepad or WordPad.

If you copy and paste the code into either of those programs, replace all of the quotes, then resave it under the original file name, it just may solve your problem.
 
Posts: 1154 | Location: Australia | Registered: April 17, 2007Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
thanks postyr I will try that tonight after work.
Congratulations Larry the short time i've been here i think you deserve a medal! fantastic forum!
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
Honorary Mechanic
Picture of Kirk
Posted Hide Post
Go here and click on "Installer" to download the program exe. Once downloaded, run the program and you'll have a code editor.
 
Posts: 211 | Registered: July 22, 2007Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Posted Hide Post
thank you kirk it worked fine. It seems that the php code is ok now, except I now have the following sql error : Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Inetpub\vhosts\ozboatadvisor.ihostvm.com\httpdocs\register.php on line 25
Table 'obamembers.users' doesn't exist
i created the database on the server as per instructions and called it obamembers. There is a reference to "users" in the php code about three times in mysql queries, where does that come from? the origin of all this is
http://www.swish-db.com/tutorials/view.php/tid/601
would appreciate any help to get this registration and login to work on my site
THANK YOU
 
Posts: 14 | Registered: October 01, 2009Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community Page 1 2  
 


™ & © 1998 - 2008, Virtual Mechanics Inc. All rights reserved.