Jump to content

Newbie Assistance with website creation


Recommended Posts

Hi,

 

I am very new to this website creation game and have now hit some roadblocks. Let me tell you what my goal is.

 

I participate in a small group of people who plays an online game creating movies. This has been going on for many years and I am now trying to create a kind of IMDB style site which shows all the movies, actors, directors, writers etc.

 

I have created my main page (although not too pretty yet) at crazymoonpics.heliohost.org/

 

This is OK and have followed dreamweaver guides on setting this up. However I have several issues.

 

1. If you view this site in google chrome it is displaying ok with the vertical menubar etc. In IE this does not display correctly which means I have coded something wrong so it is not showing properly. Can you point me in the right direction?

 

2. Now I have this page the idea is to create a form that allows the players to add their movies into a table. Then I want to create pages that take the information from that table to create pages for movis, directors (basically everything in the CMP Movie Database section).

 

I have created a form within dreamweaver but how can I tell it to populate the SQL table i have created in cPanel?

 

I cannot find a good guide on this so far.

 

I am sure I will have many more questions once I have this working but for now I think this will be a very helpful starting point if someone can help.

 

Thank you very much in advance for any help you can offer.

 

CMPAdmin

Link to comment
Share on other sites

1. Although I do not have access to Internet Explorer at the moment, I have noticed an error with your code. In your HTML you start lots of <p> tags, but never end them with </p>. This could be the reason.

 

2. Basically, you first need to create a MySQL Table in your database to store the information. To do this, go into your cPanel and click on phpMyAdmin. After selecting your database from the list on the left sidebar, click on the SQL tab at the top of the screen and enter the following code. Change it to suit your preferences.

CREATE TABLE `movies` (
`id` int(4) NOT NULL auto_increment,
`name` varchar(65) NOT NULL default '',
`director` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2;

 

This will create the table with the column 'id' which is required and two more columns, 'name' and 'director'. Now, to insert a row, you will need to use a PHP script. Create a HTML form like this one where users can input the details:

<form method=post action=add.php>
Name: <input type=text name=name>
Director: <input type=text name=director>
<input type=submit name=Add Movie>
</form>

 

The above code will make a simple form. Feel free to style it in any way you can. Now create a new file called add.php with this code (fill in the gaps)

<?php

// Connect to the database
mysql_connect('localhost', 'cmpadmin_user', 'password') or die('<h1>Cannot connect to database!</h1>');
mysql_select_db('cmpadmin_dbname') or die('<h1>Cannot select database!</h1>');

// Get the input and assign to variables
$name = $_POST['name'];
$director = $_POST['director'];

// Randomly select an id
$id = rand();

// Insert the record into the database
mysql_query("INSERT INTO `members` VALUES (".$id.", '".$name."', '".$director."')");
?>

<html>
<head>
<title>Crazy Moon Pictures</title>
</head>
<body>
<h1>Done.</h1>
</body>
</html>

 

Now you can retrieve the records from the MySQL Database. ;)

Link to comment
Share on other sites

OK so far so good. Thank you all for your help.

 

I do have one more question with regards to my form.

 

I want them to be able to fill in the cast of the movie.

 

So I have created a field in my form called cast and made it a multiline text field.

 

So in theory they will input

 

actor 1

actor 2

actor 3

 

Then when they submit i want that to add those items to the cast column in the SQL table.

 

Later I will want to be able to search for a film and it display all of the info about that film on a page (nicly formatted). Will it be able to get this information and treat each cast member seperately or would it be best to create lots of fields on my form and table e.g.

 

cast member 1 -

cast member 2 -

 

etc etc

 

 

 

Link to comment
Share on other sites

If I may make a suggestion ...

Make your life easier & use Wordpress or Joomla :)

 

Yeah I think baby steps are required for me.

 

I am already learning Dreamweaver, php, html and heliohost. Adding Joomla and/or another service will be too much I think. Plus I think learning it this way is very helpful for me so would prefer to learn the 'traditional' ways.

 

Thank you for the tip though.

Link to comment
Share on other sites

Yeah I think baby steps are required for me.

 

I am already learning Dreamweaver, php, html and heliohost. Adding Joomla and/or another service will be too much I think. Plus I think learning it this way is very helpful for me so would prefer to learn the 'traditional' ways.

 

Thank you for the tip though.

Ahhh ... Well your welcome :)

If your learning the 'traditional' ways, the HelioNet will be a big help :)

Link to comment
Share on other sites

1. Although I do not have access to Internet Explorer at the moment, I have noticed an error with your code. In your HTML you start lots of <p> tags, but never end them with </p>. This could be the reason.

 

2. Basically, you first need to create a MySQL Table in your database to store the information. To do this, go into your cPanel and click on phpMyAdmin. After selecting your database from the list on the left sidebar, click on the SQL tab at the top of the screen and enter the following code. Change it to suit your preferences.

CREATE TABLE `movies` (
`id` int(4) NOT NULL auto_increment,
`name` varchar(65) NOT NULL default '',
`director` varchar(65) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2;

 

This will create the table with the column 'id' which is required and two more columns, 'name' and 'director'. Now, to insert a row, you will need to use a PHP script. Create a HTML form like this one where users can input the details:

<form method=post action=add.php>
Name: <input type=text name=name>
Director: <input type=text name=director>
<input type=submit name=Add Movie>
</form>

 

The above code will make a simple form. Feel free to style it in any way you can. Now create a new file called add.php with this code (fill in the gaps)

<?php

// Connect to the database
mysql_connect('localhost', 'cmpadmin_user', 'password') or die('<h1>Cannot connect to database!</h1>');
mysql_select_db('cmpadmin_dbname') or die('<h1>Cannot select database!</h1>');

// Get the input and assign to variables
$name = $_POST['name'];
$director = $_POST['director'];

// Randomly select an id
$id = rand();

// Insert the record into the database
mysql_query("INSERT INTO `members` VALUES (".$id.", '".$name."', '".$director."')");
?>

<html>
<head>
<title>Crazy Moon Pictures</title>
</head>
<body>
<h1>Done.</h1>
</body>
</html>

 

Now you can retrieve the records from the MySQL Database. ;)

 

 

Hi,

 

After following your instructions I think I am pretty close. Thank you for all your help so far.

 

I have created my php code but when I click the submit button i receive a cannot select database! error. My code is below and from what I can see I have not changed anything from what you originally wrote (obviously some of the names have changed in the variables to match mine. Any ideas what I have done wrong?

 

<?php

 

// Connect to the database

mysql_connect('localhost', 'cmpadm_xxxx', 'xxxx') or die('<h1>Cannot connect to database!</h1>');

mysql_select_db('cmpadmin_moviesdb') or die('<h1>Cannot select database!</h1>');

 

// Get the input and assign to variables

$movieName = $_POST['movieName'];

$genre = $_POST['genre'];

$directorName = $_POST['directorName'];

$producerName = $_POST['producerName'];

$writerName1 = $_POST['writerName1'];

$writerName2 = $_POST['writerName2'];

$writerName3 = $_POST['writerName3'];

$castMember1 = $_POST['castMember1'];

$castMember2 = $_POST['castMember2'];

$castMember3 = $_POST['castMember3'];

$castMember4 = $_POST['castMember4'];

$castMember5 = $_POST['castMember5'];

$castMember6 = $_POST['castMember6'];

$castMember7 = $_POST['castMember7'];

$castMember8 = $_POST['castMember8'];

$castMember9 = $_POST['castMember9'];

$castMember10 = $_POST['castMember10'];

$plot = $_POST['plot'];

$boxOffice = $_POST['boxOffice'];

$netLossGain = $_POST['netLossGain'];

$posterURL = $_POST['poster'];

 

// Randomly select an id

$id = rand();

 

// Insert the record into the database

mysql_query("INSERT INTO `members` VALUES (".$id.", '".$movieName."', '".$genre."', '".$directorName."', '".$producerName."',

'".$writerName1."', '".$writerName2."', '".$writerName3."', '".$castMember1."', '".$castMember2."', '".$castMember3."',

'".$castMember4."', '".$castMember5."', '".$castMember6."', '".$castMember7."', '".$castMember8."', '".$castMember9."',

'".$castMember10."')");

?>

 

 

 

Link to comment
Share on other sites

New question of the day!

 

So I now have the basic setup of my site. Nothing too fancy just yet. Keen to get things working then I can make it pretty.

 

On the site crazymoonpics.heliohost.org, there is a section that allows you to add a movie into the tbMovies table in SQL. Instead of letting users input their own names which could lead to spelling mistakes and other weirdness I have added a series of dropdowns.

 

What I have also done is crate a tbPerson table in SQL that will hold of the various people that could be selected.

 

What I now need to do is somehow populate my drop downs with the names stored in this tbPerson table.

 

I cannot figure out how to do this. I am sure it involves PHP but the form already calls on my add.php page to submit the form. How to I set something up to also do this population?

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...