Jump to content

Recommended Posts

Hi,

 

I have a music website, with many artists. I'd like to create an admin section to streamline the updating process and make it quicker and easier for me. It means a form to input text (name, surname, band name, etc), image files (artist pic) and audio files (mp3 files).  I tried different programs but they are too bloated for me (Joomla, Jamroom, Websitebaker could have worked, but didn't).

 

I'm new to PHP, I'm using a tutorial online. I started creating a form to insert informations that would then appear on my website. so far I have 2 files created: one is html and the other one is php. However, when I click on OK to submit the info, I get the html page showing the php code. I'm already stomped... not good...

 

I'm creating the files and look and feel in Homesite, a text web editor (no wysiwyg).

 

Anyone can help me figure this out?

 

Thanks!

 

styzer

 

 

Hey thanks:

 

Sure.

 

HMTL

 

<div align="right" style="width:250px;padding:10px;background-color:#153242;color:#FFFFFF;">
<form method="post" action="verif.php">
Name : <input type="text" name="nom" size="20"><br>
First name : <input type="text" name="prenom" size="20"><br>
Band name: <input type="text" name="bandname" size="20"><br>
URL : <input type="text" name="url" size="20" value="http://"><br>
<br>

<input type="submit" value="OK"> 

</form>
</div>

 

Here is the php file (verif.php,  in the same folder, so the path is right):

 

<?php
$prenom = $_POST['prenom'];
$nom = $_POST['nom'];
$bandname = $_POST['bandname'];
$url = $_POST['url'];

if(empty($titre))
{
print("<center>Le '<b>Titre</b>' est vide !</center>");
exit();
}
// vérification du début de l'url
$verif_url = strtolower($url);
$verif_url = substr("$verif_url", 0, 7);
// on verifie les 7 premiers caractères
if ($verif_url!="http://")
{
print("L'URL doit commencer par <b>http://</b>");
exit();
}
else
{
print("$titre : <a href=\"$url\">$url</a>");
}

print("<center>Bonjour $prenom $nom $bandname $url</center>");
?> 

 

Thanks for looking into it,

 

styzer

 

 

ah yes, I have to take "titre" out. Thanks for noticing.

 

As far as security, that would be my most challenging task. So far, I'm just babbling, and not going very far. Tutorials don't always take into account newbies need clear layouts... :)  You have a tutorial for starting up which you recommend?

 

Thanks all, it's awesome to get responses so quickly!

 

styzer

Basic rules...

 

Data that will be part of an SQL query: mysql_real_escape_string($_POST['data']);

 

http://us3.php.net/mysql_real_escape_string

 

Data that will be displayed on page: stripslashes(htmlentities($_POST['data'], ENT_QUOTES));

 

http://us3.php.net/stripslashes

http://us3.php.net/htmlentities

 

ctype_??? <-- very usefull

http://us3.php.net/ctype

 

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.