Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1794
  • Last Modified:

Mysql Phpmyadmin how to set a random default value in a column?

I need to generate a random e-mail address in my database , so the system i am using goes though the registration process,  

IS there any way to make a trick to generate a email ( text string) on each new created column so it fills the value as   random@email.com ...

????
0
TonyReba
Asked:
TonyReba
  • 3
  • 3
  • 2
2 Solutions
 
m4trixCommented:
Yup. I think this is what you want:

Select the table that contains the email address column. go to the Structure tab, select the checkbox for the email column. Click "Change" at the bottom of the table (pencil icon?). Under "Default", select "As Defined:" from the first field, and enter "random@email.com" in the second field. Click "save", and from now on, any time a new row is created, it will default to "random@email.com" for that column
0
 
m4trixCommented:
Oh, it just occured to me that you might want to have a completely unique email address created each time a new row is created. I don't think you can do that, because default values must be constants (with one exception -> CURRENT_TIMESTAMP for a TIMESTAMP column). You would have to add a new row, and then update it with a random email as a separate query - but if you're going to do that you might as well just create the row with the random email in the first place. That would have to be implemented in the code that fills the database rather than in the database itself
0
 
TonyRebaAuthor Commented:
Sorry I didnt really explain it very well, I do have that , but need to generate

random1@email.com
random2@email.com
random3@email.com
 and so on........................
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
TonyRebaAuthor Commented:
That would have to be implemented in the code that fills the database rather than in the database itself.........


that was i was affraid off,,,,,, Is going to be a hasle to find the code that insert (Joomla)
0
 
m4trixCommented:
hard to say... I'm not familiar with joomla, and I'm not exactly sure what you're trying to do. Surely people have to submit a valid email when they register in the first place.  good luck!
0
 
TonyRebaAuthor Commented:
do you know how can initialize my form field in php to a random email?

0
 
cybertaiCommented:
You will need to set the email form value to a random email

$randomemail =  rand()."@email.com";
0
 
cybertaiCommented:
Look for the email box, replace it with:
<input name="emailfield" type="text" id="emailfield" value="<?php echo rand()."@email.com"; ?>" />
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now