Jump to content

Recommended Posts

I am creating an email validation system. I have added this to my verify.php page.

 

<?php
if (isset($code))
{
    @mysql_connect("localhost", "username", "password");
    @mysql_select_db("database");
    $query = "SELECT username FROM verification WHERE verification_number = $code";
  $result = @mysql_query($query);
  $row = @mysql_fetch_array('$result', MYSQL_ASSOC);
  echo $row['username'];
} 
?>

 

I was told to add the "@" symbol to each of my functions for connecting to the database to avoid the MySQL syntax error. However, my script is not working correctly. No information is being displayed. The $code variable is in the browser. (i.e. http://www.example.com/verify.php?code=f546b352205652bbdeab043bc9a030762ef5b5). I have checked to make sure that the code I am entering into my browser is indeed in the database. I had previously changed my Global Variables to On in my PHP.ini file. My host is http://www.hostmonster.com . Oh, I also replaced my actual database information with the information you see up there now. Just so you know. xD

Link to comment
https://forums.phpfreaks.com/topic/55377-solved-email-validation/
Share on other sites

I removed every @ symbol but as I said before it results in an error.

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/malevol1/public_html/arderia/verify.php on line 13

 

I had the query the database function in my script but I removed the one I had and added the one you suggested in my script because of the die function with it. It showed no change.

Try doing:

 

<?php
if (isset($code)) {
    $code = preg_replace('|[^A-z0-9]|', '', $code);
    $dbconn = @mysql_connect($dbhost, $dbuser, $dbpass) or die('MySQL Error: Could not establish a connection to the databse.');
    @mysql_select_db($dbname, $dbconn) or die('MySQL Error: Could not locate the specified database');
    $query = 'SELECT `username` FROM `verification` WHERE `verification_number` = "'.$code.'"';
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    echo $row['username'];
} 
?>

Not sure if you are but you come across as a beginner in PHP. I would honestly highly recommend you disable register_globals and use $_POST and $_GET variables to fetch objects from your URL.

 

Register_globals isn't unsafe itself but if you don't know what you are doing it can be very very unsafe.

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.